diff --git a/Cargo.lock b/Cargo.lock index 500b622c..53ff4d20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -579,23 +579,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "example-wasm" -version = "0.1.0" -dependencies = [ - "base64", - "chrono", - "prettyplease", - "progenitor", - "progenitor-client", - "reqwest", - "serde", - "serde_json", - "syn", - "uuid", - "wasm-bindgen-test", -] - [[package]] name = "expectorate" version = "1.2.0" @@ -788,6 +771,40 @@ dependencies = [ "wasi 0.14.7+wasi-0.2.4", ] +[[package]] +name = "gloo-net" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06f627b1a58ca3d42b45d6104bf1e1a03799df472df00988b6ba21accc10580" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "http", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror 1.0.69", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "h2" version = "0.4.12" @@ -1261,16 +1278,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "minicov" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" -dependencies = [ - "cc", - "walkdir", -] - [[package]] name = "mio" version = "1.0.4" @@ -1457,6 +1464,26 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -1590,6 +1617,8 @@ version = "0.11.2" dependencies = [ "bytes", "futures-core", + "gloo-net", + "js-sys", "percent-encoding", "reqwest", "serde", @@ -1597,6 +1626,9 @@ dependencies = [ "serde_urlencoded", "url", "uuid", + "wasm-bindgen", + "wasm-streams", + "web-sys", ] [[package]] @@ -2932,30 +2964,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-bindgen-test" -version = "0.3.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e381134e148c1062f965a42ed1f5ee933eef2927c3f70d1812158f711d39865" -dependencies = [ - "js-sys", - "minicov", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b673bca3298fe582aeef8352330ecbad91849f85090805582400850f8270a2e8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "wasm-streams" version = "0.4.2" diff --git a/Cargo.toml b/Cargo.toml index b86f3b7c..53c0cfb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,13 +3,16 @@ members = [ "cargo-progenitor", "example-build", "example-macro", - "example-wasm", "progenitor", "progenitor-client", "progenitor-impl", "progenitor-macro", ] +# example-wasm is excluded from workspace because it uses gloo-client feature +# which conflicts with other members using reqwest-client +exclude = ["example-wasm"] + resolver = "2" [workspace.dependencies] @@ -57,7 +60,7 @@ typify = { version = "0.5.0" } # typify = { git = "https://github.com/oxidecomputer/typify" } url = "2.5.7" unicode-ident = "1.0.22" -uuid = { version = "1.19.0", features = ["serde", "v4"] } +uuid = { version = "1.19.0", features = ["serde", "v4", "js"] } #[patch."https://github.com/oxidecomputer/typify"] #typify = { path = "../typify/typify" } diff --git a/README.md b/README.md index 05f5caac..a1d9d840 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,20 @@ Progenitor may fail for some OpenAPI documents. If you encounter a problem, you can help the project by filing an issue that includes the OpenAPI document that produced the problem. +## HTTP Backend + +Progenitor supports two HTTP backends: + +- `reqwest-client`: Uses [reqwest](https://crates.io/crates/reqwest) for HTTP operations. Works on native targets and WASM. Best for server-side applications and native CLI tools. + +- `gloo-client`: Uses [gloo-net](https://crates.io/crates/gloo-net) for HTTP operations. Designed specifically for WASM/browser environments. Produces smaller bundles than reqwest and leverages the browser's native Fetch API. + +Differences of `gloo-net` compared to `reqwest`: + +- Only works on browser targets (`wasm32-unknown-unknown`) +- WebSocket uses `web_sys::WebSocket` directly instead of HTTP protocol upgrade +- Connection pooling, timeouts, and TLS are handled by the browser and not configurable in code + ## Using Progenitor There are three different ways of using the `progenitor` crate. The one you @@ -38,12 +52,13 @@ You'll need to add the following to `Cargo.toml`: ```toml [dependencies] -futures = "0.3" progenitor = { git = "https://github.com/oxidecomputer/progenitor" } -reqwest = { version = "0.12", features = ["json", "stream"] } +progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", features = ["reqwest-client"] } serde = { version = "1.0", features = ["derive"] } ``` +For the gloo backend (WASM/browser), use `features = ["gloo-client"]` instead: + In addition, if the OpenAPI document contains string types with the `format` field set to `date` or `date-time`, include @@ -131,20 +146,19 @@ You'll need to add the following to `Cargo.toml`: ```toml [dependencies] -futures = "0.3" -progenitor-client = { git = "https://github.com/oxidecomputer/progenitor" } -reqwest = { version = "0.12", features = ["json", "stream"] } +progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", features = ["reqwest-client"] } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" [build-dependencies] prettyplease = "0.2.22" -progenitor = { git = "https://github.com/oxidecomputer/progenitor" } +progenitor = { git = "https://github.com/oxidecomputer/progenitor", default-features = false } serde_json = "1.0" syn = "2.0" ``` -(`chrono`, `uuid`, `base64`, and `rand` as above) +For the gloo backend, use `features = ["gloo-client"]` in the progenitor-client dependency. + +(`chrono`, `uuid`, `base64`, and `rand` as above depending on your OpenAPI spec) Note that `progenitor` is used by `build.rs`, but the generated code required `progenitor-client`. @@ -157,7 +171,7 @@ however, the most manual way to use Progenitor. Usage: -``` +```bash cargo progenitor Options: @@ -169,13 +183,14 @@ Options: For example: -``` +```bash cargo install cargo-progenitor cargo progenitor -i sample_openapi/keeper.json -o keeper -n keeper -v 0.1.0 ``` ... or within the repo: -``` + +```bash cargo run --bin cargo-progenitor -- progenitor -i sample_openapi/keeper.json -o keeper -n keeper -v 0.1.0 ``` @@ -396,4 +411,4 @@ Currently, the generated code doesn't deal with request headers. To add default .unwrap(); let client = Client::new_with_client(baseurl, client_with_custom_defaults); -``` \ No newline at end of file +``` diff --git a/cargo-progenitor/Cargo.toml b/cargo-progenitor/Cargo.toml index 1797ad29..f4b12a74 100644 --- a/cargo-progenitor/Cargo.toml +++ b/cargo-progenitor/Cargo.toml @@ -13,7 +13,7 @@ default-run = "cargo-progenitor" [dependencies] progenitor = { workspace = true, default-features = false } -progenitor-client = { workspace = true } +progenitor-client = { workspace = true, features = ["reqwest-client"] } progenitor-impl = { workspace = true } anyhow = { workspace = true } diff --git a/cargo-progenitor/src/main.rs b/cargo-progenitor/src/main.rs index 191675a7..6763aaf9 100644 --- a/cargo-progenitor/src/main.rs +++ b/cargo-progenitor/src/main.rs @@ -10,7 +10,7 @@ use anyhow::{bail, Result}; use clap::{Parser, ValueEnum}; use openapiv3::OpenAPI; use progenitor::{GenerationSettings, Generator, InterfaceStyle, TagStyle}; -use progenitor_impl::space_out_items; +use progenitor_impl::{space_out_items, HttpBackend}; fn is_non_release() -> bool { cfg!(debug_assertions) @@ -51,6 +51,9 @@ struct Args { /// SDK tag style #[clap(value_enum, long, default_value_t = TagArg::Merged)] tags: TagArg, + /// HTTP backend to use + #[clap(value_enum, long, default_value_t = BackendArg::Reqwest)] + backend: BackendArg, /// Include client code rather than depending on progenitor-client #[clap(default_value = match is_non_release() { true => "true", false => "false" }, long, action = clap::ArgAction::Set)] include_client: bool, @@ -86,6 +89,21 @@ impl From for TagStyle { } } +#[derive(Copy, Clone, ValueEnum)] +enum BackendArg { + Reqwest, + Gloo, +} + +impl From for HttpBackend { + fn from(arg: BackendArg) -> Self { + match arg { + BackendArg::Reqwest => HttpBackend::Reqwest, + BackendArg::Gloo => HttpBackend::Gloo, + } + } +} + fn reformat_code(input: String) -> String { let config = rustfmt_wrapper::config::Config { normalize_doc_attributes: Some(true), @@ -116,10 +134,20 @@ fn main() -> Result<()> { let CargoCli::Progenitor(args) = CargoCli::parse(); let api = load_api(&args.input)?; + // Validate backend and include_client compatibility + if args.include_client && matches!(args.backend, BackendArg::Gloo) { + bail!( + "The --include-client flag is not supported with --backend gloo. \ + The gloo backend requires specific WASM dependencies that should be managed via Cargo.toml. \ + Use --include-client false and add 'progenitor-client = {{ version = \"...\", features = [\"gloo-client\"] }}' to your dependencies." + ); + } + let mut builder = Generator::new( GenerationSettings::default() .with_interface(args.interface.into()) - .with_tag(args.tags.into()), + .with_tag(args.tags.into()) + .with_backend(args.backend.into()), ); match builder.generate_tokens(&api) { @@ -164,7 +192,7 @@ fn main() -> Result<()> { [dependencies]\n\ {}\n\ \n", - dependencies(builder, args.include_client).join("\n"), + dependencies(builder, args.backend.into(), args.include_client).join("\n"), ) .chars(), ); @@ -214,6 +242,9 @@ struct Dependencies { bytes: &'static str, chrono: &'static str, futures: &'static str, + getrandom: &'static str, + gloo_net: &'static str, + js_sys: &'static str, percent_encoding: &'static str, rand: &'static str, regress: &'static str, @@ -222,6 +253,9 @@ struct Dependencies { serde_json: &'static str, serde_urlencoded: &'static str, uuid: &'static str, + wasm_bindgen: &'static str, + wasm_streams: &'static str, + web_sys: &'static str, } static DEPENDENCIES: Dependencies = Dependencies { @@ -229,6 +263,9 @@ static DEPENDENCIES: Dependencies = Dependencies { bytes: "1.9", chrono: "0.4", futures: "0.3", + getrandom: "0.2", + gloo_net: "0.6", + js_sys: "0.3", percent_encoding: "2.3", rand: "0.8", regress: "0.10", @@ -237,17 +274,37 @@ static DEPENDENCIES: Dependencies = Dependencies { serde_json: "1.0", serde_urlencoded: "0.7", uuid: "1.0", + wasm_bindgen: "0.2", + wasm_streams: "0.4", + web_sys: "0.3", }; -pub fn dependencies(builder: Generator, include_client: bool) -> Vec { +pub fn dependencies(builder: Generator, backend: HttpBackend, include_client: bool) -> Vec { let mut deps = vec![ - format!("bytes = \"{}\"", DEPENDENCIES.bytes), - format!("futures-core = \"{}\"", DEPENDENCIES.futures), - format!("reqwest = {{ version = \"{}\", default-features=false, features = [\"json\", \"stream\"] }}", DEPENDENCIES.reqwest), format!("serde = {{ version = \"{}\", features = [\"derive\"] }}", DEPENDENCIES.serde), format!("serde_urlencoded = \"{}\"", DEPENDENCIES.serde_urlencoded), ]; + // Add backend-specific dependencies + match backend { + HttpBackend::Reqwest => { + deps.push(format!("bytes = \"{}\"", DEPENDENCIES.bytes)); + deps.push(format!("futures-core = \"{}\"", DEPENDENCIES.futures)); + deps.push(format!("reqwest = {{ version = \"{}\", default-features=false, features = [\"json\", \"stream\"] }}", DEPENDENCIES.reqwest)); + } + HttpBackend::Gloo => { + deps.push(format!("futures-core = \"{}\"", DEPENDENCIES.futures)); + deps.push(format!("gloo-net = \"{}\"", DEPENDENCIES.gloo_net)); + deps.push(format!("js-sys = \"{}\"", DEPENDENCIES.js_sys)); + deps.push(format!("wasm-bindgen = \"{}\"", DEPENDENCIES.wasm_bindgen)); + deps.push(format!("wasm-streams = \"{}\"", DEPENDENCIES.wasm_streams)); + deps.push(format!( + "web-sys = {{ version = \"{}\", features = [\"Blob\", \"File\", \"FormData\", \"Headers\", \"ReadableStream\", \"Request\", \"RequestCredentials\", \"RequestInit\", \"RequestMode\", \"Response\", \"WebSocket\"] }}", + DEPENDENCIES.web_sys + )); + } + } + let type_space = builder.get_type_space(); let mut needs_serde_json = false; @@ -265,7 +322,11 @@ pub fn dependencies(builder: Generator, include_client: bool) -> Vec { } else { "*" }; - let client_version_dep = format!("progenitor-client = \"{}\"", crate_version); + let backend_feature = match backend { + HttpBackend::Reqwest => "reqwest-client", + HttpBackend::Gloo => "gloo-client", + }; + let client_version_dep = format!("progenitor-client = {{ version = \"{}\", features = [\"{}\"] }}", crate_version, backend_feature); deps.push(client_version_dep); } @@ -273,10 +334,22 @@ pub fn dependencies(builder: Generator, include_client: bool) -> Vec { deps.push(format!("regress = \"{}\"", DEPENDENCIES.regress)); } if type_space.uses_uuid() { + let uuid_features = match backend { + HttpBackend::Reqwest => "\"serde\", \"v4\"", + HttpBackend::Gloo => "\"serde\", \"v4\", \"js\"", + }; deps.push(format!( - "uuid = {{ version = \"{}\", features = [\"serde\", \"v4\"] }}", - DEPENDENCIES.uuid + "uuid = {{ version = \"{}\", features = [{}] }}", + DEPENDENCIES.uuid, uuid_features )); + + // Add getrandom with js feature, which is needed by uuid on WASM. + if matches!(backend, HttpBackend::Gloo) { + deps.push(format!( + "getrandom = {{ version = \"{}\", features = [\"js\"] }}", + DEPENDENCIES.getrandom + )); + } } if type_space.uses_chrono() { deps.push(format!( @@ -290,6 +363,14 @@ pub fn dependencies(builder: Generator, include_client: bool) -> Vec { if builder.uses_websockets() { deps.push(format!("base64 = \"{}\"", DEPENDENCIES.base64)); deps.push(format!("rand = \"{}\"", DEPENDENCIES.rand)); + + // Add getrandom with js feature, which is needed by rand on WASM. + if matches!(backend, HttpBackend::Gloo) && !type_space.uses_uuid() { + deps.push(format!( + "getrandom = {{ version = \"{}\", features = [\"js\"] }}", + DEPENDENCIES.getrandom + )); + } } if type_space.uses_serde_json() || needs_serde_json { deps.push(format!("serde_json = \"{}\"", DEPENDENCIES.serde_json)); diff --git a/docs/implementing-client.md b/docs/implementing-client.md index 52be752c..0592d98e 100644 --- a/docs/implementing-client.md +++ b/docs/implementing-client.md @@ -1,17 +1,14 @@ # Implementing the client -Once you have generated your client, you'll notice there are two methods to -create a new `Client`; `Client::new()` and `Client::new_with_client()`. - -The first method will create a basic client without any headers or -customizations that aren't already in your OpenAPI specification file: +Once you have generated your client, all generated clients have a `Client::new()` method: ```rust let client = Client::new("https://foo/bar"); ``` -Should you need to set custom headers or other `reqwest::ClientBuilder` -methods, you can use `Client::new_with_client()` as shown below. +## reqwest backend + +For the reqwest backend, there is also a `Client::new_with_client()` method that allows you to customize the underlying HTTP client. ```rust let mut val = reqwest::header::HeaderValue::from_static("super-secret"); @@ -28,9 +25,28 @@ let client_builder = reqwest::ClientBuilder::new() .build() .unwrap(); -let client Client::new_with_client("https://foo/bar", client_builder); +let client = Client::new_with_client("https://foo/bar", client_builder); ``` For more information on available methods, see the [reqwest](https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html) -documentation. \ No newline at end of file +documentation. + +## gloo backend + +The gloo backend does not have `Client::new_with_client()` because it uses the browser's native Fetch API. HTTP behavior (timeouts, headers, credentials, etc.) is controlled by the browser and request options. + +For custom request behavior, you can implement the `ClientHooks` trait to intercept and modify requests: + +```rust +impl ClientHooks for &Client { + async fn pre( + &self, + request: &mut gloo_net::http::Request, + info: &OperationInfo, + ) -> Result<(), Error> { + // Modify request before sending + Ok(()) + } +} +``` diff --git a/docs/progenitor-client.md b/docs/progenitor-client.md index 6e1f43fb..49507412 100644 --- a/docs/progenitor-client.md +++ b/docs/progenitor-client.md @@ -7,10 +7,10 @@ different ways (see ["Using Progenitor"](../README.md#using_progenitor)). - For macro consumers, it comes from the `progenitor` dependency. -- For builder consumers, it must be specified under `[dependencies]` (while `progenitor` is under `[build-dependencies]`). +- For builder consumers, it must be specified under `[dependencies]` with either the `reqwest-client` or `gloo-client` feature (while `progenitor` is under `[build-dependencies]`). - For statically generated consumers, the code is emitted into - `src/progenitor_client.rs`. + `src/progenitor_client.rs` when using `--include-client` (reqwest backend only). The two types that `progenitor-client` exports are `Error` and `ResponseValue`. A typical generated method will use these types in its @@ -45,8 +45,8 @@ These are the relevant implementations for `ResponseValue`: pub struct ResponseValue { .. } impl ResponseValue { - pub fn status(&self) -> &reqwest::StatusCode { .. } - pub fn headers(&self) -> &reqwest::header::HeaderMap { .. } + pub fn status(&self) -> u16 { .. } + pub fn headers(&self) -> &HeadersWrapper { .. } pub fn into_inner(self) -> T { .. } } impl std::ops::Deref for ResponseValue { @@ -58,6 +58,8 @@ impl std::ops::DerefMut for ResponseValue { .. } impl std::fmt::Debug for ResponseValue { .. } ``` +Note: The exact types for `headers()` differ by backend (`reqwest::header::HeaderMap` for reqwest, `HeadersWrapper` for gloo). + It can be used as the type `T` in most instances and extracted as a `T` using `into_inner()`. @@ -86,7 +88,9 @@ There are seven sub-categories of error covered by the error type variants: - A custom error, particular to the generated client -These errors are covered by the variants of the `Error` type: +These errors are covered by the variants of the `Error` type. The exact variant types differ by backend: + +**`reqwest` backend:** ```rust pub enum Error { @@ -100,3 +104,17 @@ pub enum Error { Custom(String), } ``` + +**`gloo-net` backend:** + +```rust +pub enum Error { + InvalidRequest(String), + CommunicationError(String), + ErrorResponse(ResponseValue), + ResponseBodyError(String), + InvalidResponsePayload(String, serde_json::Error), + UnexpectedResponse(gloo_net::http::Response), + Custom(String), +} +``` diff --git a/example-wasm/Cargo.lock b/example-wasm/Cargo.lock new file mode 100644 index 00000000..a6c3029e --- /dev/null +++ b/example-wasm/Cargo.lock @@ -0,0 +1,1080 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "bytes" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.2.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0aeaff4ff1a90589618835a598e545176939b97874f7abc7851caa0618f203" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "example-wasm" +version = "0.1.0" +dependencies = [ + "base64", + "chrono", + "futures-core", + "getrandom 0.2.16", + "gloo-net", + "js-sys", + "prettyplease", + "progenitor", + "progenitor-client", + "serde", + "serde_json", + "serde_urlencoded", + "syn", + "uuid", + "wasm-bindgen", + "wasm-bindgen-test", + "wasm-streams", + "web-sys", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "gloo-net" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06f627b1a58ca3d42b45d6104bf1e1a03799df472df00988b6ba21accc10580" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "http", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror 1.0.69", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "indexmap" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" +dependencies = [ + "equivalent", + "hashbrown", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.178" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091" + +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "minicov" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "openapiv3" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8d427828b22ae1fff2833a03d8486c2c881367f1c336349f307f321e7f4d05" +dependencies = [ + "indexmap", + "serde", + "serde_json", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9695f8df41bb4f3d222c95a67532365f569318332d03d5f3f67f37b20e6ebdf0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "progenitor" +version = "0.11.2" +dependencies = [ + "progenitor-impl", +] + +[[package]] +name = "progenitor-client" +version = "0.11.2" +dependencies = [ + "futures-core", + "gloo-net", + "js-sys", + "percent-encoding", + "serde", + "serde_json", + "serde_urlencoded", + "wasm-bindgen", + "wasm-streams", + "web-sys", +] + +[[package]] +name = "progenitor-impl" +version = "0.11.2" +dependencies = [ + "heck", + "http", + "indexmap", + "openapiv3", + "proc-macro2", + "quote", + "regex", + "schemars", + "serde", + "serde_json", + "syn", + "thiserror 2.0.17", + "typify", + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + +[[package]] +name = "regress" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2057b2325e68a893284d1538021ab90279adac1139957ca2a74426c6f118fb48" +dependencies = [ + "hashbrown", + "memchr", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schemars" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" +dependencies = [ + "chrono", + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", + "uuid", +] + +[[package]] +name = "schemars_derive" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_tokenstream" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64060d864397305347a78851c51588fd283767e7e7589829e8121d65512340f1" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slab" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" + +[[package]] +name = "syn" +version = "2.0.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21f182278bf2d2bcb3c88b1b08a37df029d71ce3d3ae26168e3c653b213b99d4" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +dependencies = [ + "thiserror-impl 2.0.17", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "typify" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5bcc6f62eb1fa8aa4098f39b29f93dcb914e17158b76c50360911257aa629" +dependencies = [ + "typify-impl", + "typify-macro", +] + +[[package]] +name = "typify-impl" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1eb359f7ffa4f9ebe947fa11a1b2da054564502968db5f317b7e37693cb2240" +dependencies = [ + "heck", + "log", + "proc-macro2", + "quote", + "regress", + "schemars", + "semver", + "serde", + "serde_json", + "syn", + "thiserror 2.0.17", + "unicode-ident", +] + +[[package]] +name = "typify-macro" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "911c32f3c8514b048c1b228361bebb5e6d73aeec01696e8cc0e82e2ffef8ab7a" +dependencies = [ + "proc-macro2", + "quote", + "schemars", + "semver", + "serde", + "serde_json", + "serde_tokenstream", + "syn", + "typify-impl", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "uuid" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a" +dependencies = [ + "getrandom 0.3.4", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e90e66d265d3a1efc0e72a54809ab90b9c0c515915c67cdf658689d2c22c6c" +dependencies = [ + "async-trait", + "cast", + "js-sys", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7150335716dce6028bead2b848e72f47b45e7b9422f64cccdc23bedca89affc1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "zmij" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3280a1b827474fcd5dbef4b35a674deb52ba5c312363aef9135317df179d81b" diff --git a/example-wasm/Cargo.toml b/example-wasm/Cargo.toml index 611ec61d..af7423b5 100644 --- a/example-wasm/Cargo.toml +++ b/example-wasm/Cargo.toml @@ -5,10 +5,17 @@ edition = "2021" [dependencies] chrono = { version = "0.4", features = ["serde"] } -progenitor-client = { path = "../progenitor-client" } -reqwest = { version = "0.12.26", features = ["json", "stream"] } +progenitor-client = { path = "../progenitor-client", features = ["gloo-client"] } +gloo-net = "0.6" +js-sys = "0.3" +wasm-bindgen = "0.2" +wasm-streams = "0.4" +web-sys = { version = "0.3", features = ["WebSocket"] } base64 = "0.22" +futures-core = "0.3" +getrandom = { version = "0.2", features = ["js"] } serde = { version = "1.0", features = ["derive"] } +serde_urlencoded = "0.7" uuid = { version = "1.19", features = ["serde", "v4", "js"] } [dev-dependencies] @@ -16,6 +23,6 @@ wasm-bindgen-test = "0.3.50" [build-dependencies] prettyplease = "0.2.37" -progenitor = { path = "../progenitor" } +progenitor = { path = "../progenitor", default-features = false } serde_json = "1.0" syn = "2.0" diff --git a/example-wasm/build.rs b/example-wasm/build.rs index 2119be59..5dd4cd4d 100644 --- a/example-wasm/build.rs +++ b/example-wasm/build.rs @@ -1,4 +1,4 @@ -// Copyright 2022 Oxide Computer Company +// Copyright 2025 Oxide Computer Company use std::{ env, @@ -9,9 +9,13 @@ use std::{ fn main() { let src = "../sample_openapi/keeper.json"; println!("cargo:rerun-if-changed={}", src); + let file = File::open(src).unwrap(); let spec = serde_json::from_reader(file).unwrap(); - let mut generator = progenitor::Generator::default(); + let mut generator = progenitor::Generator::new( + progenitor::GenerationSettings::default() + .with_backend(progenitor::HttpBackend::Gloo), + ); let tokens = generator.generate_tokens(&spec).unwrap(); let ast = syn::parse2(tokens).unwrap(); diff --git a/progenitor-client/Cargo.toml b/progenitor-client/Cargo.toml index b54cc20a..aa9ab407 100644 --- a/progenitor-client/Cargo.toml +++ b/progenitor-client/Cargo.toml @@ -6,14 +6,39 @@ license = "MPL-2.0" repository = "https://github.com/oxidecomputer/progenitor.git" description = "An OpenAPI client generator - client support" +[features] +reqwest-client = ["dep:reqwest", "dep:bytes"] +gloo-client = ["dep:gloo-net", "dep:wasm-bindgen", "dep:web-sys", "dep:js-sys", "dep:wasm-streams"] + [dependencies] -bytes = { workspace = true } -futures-core = { workspace = true } percent-encoding = { workspace = true } -reqwest = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } serde_urlencoded = { workspace = true } +futures-core = { workspace = true } + +# reqwest backend +bytes = { workspace = true, optional = true } +reqwest = { workspace = true, optional = true } + +# gloo-net backend +gloo-net = { version = "0.6", optional = true } +js-sys = { version = "0.3", optional = true } +wasm-bindgen = { version = "0.2", optional = true } +wasm-streams = { version = "0.4", optional = true } +web-sys = { version = "0.3", optional = true, features = [ + "Blob", + "File", + "FormData", + "Headers", + "ReadableStream", + "Request", + "RequestCredentials", + "RequestInit", + "RequestMode", + "Response", + "WebSocket", +] } [dev-dependencies] url = { workspace = true } diff --git a/progenitor-client/src/gloo_impl.rs b/progenitor-client/src/gloo_impl.rs new file mode 100644 index 00000000..7c55773e --- /dev/null +++ b/progenitor-client/src/gloo_impl.rs @@ -0,0 +1,552 @@ +// Copyright 2025 Oxide Computer Company + +#![allow(dead_code)] + +//! Support code for generated clients using gloo-net. + +use std::ops::{Deref, DerefMut}; +use std::pin::Pin; +use std::task::{Context, Poll}; + +use futures_core::Stream; +use serde::{de::DeserializeOwned, Serialize}; +use wasm_bindgen::JsValue; + +use crate::OperationInfo; + +/// Interface for which an implementation is generated for all clients. +pub trait ClientInfo { + /// Get the version of this API. + /// + /// This string is pulled directly from the source OpenAPI document and may + /// be in any format the API selects. + fn api_version() -> &'static str; + + /// Get the base URL to which requests are made. + fn baseurl(&self) -> &str; + + /// Get the inner value of type `T` if one is specified. + fn inner(&self) -> &Inner; +} + +impl ClientInfo for &T +where + T: ClientInfo, +{ + fn api_version() -> &'static str { + T::api_version() + } + + fn baseurl(&self) -> &str { + (*self).baseurl() + } + + fn inner(&self) -> &Inner { + (*self).inner() + } +} + +/// Interface for changing the behavior of generated clients. All clients +/// implement this for `&Client`; to override the default behavior, implement +/// some or all of the interfaces for the `Client` type (without the +/// reference). This mechanism relies on so-called "auto-ref specialization". +#[allow(async_fn_in_trait, unused)] +pub trait ClientHooks +where + Self: ClientInfo, +{ + /// Runs prior to the execution of the request. This may be used to modify + /// the request before it is transmitted. + async fn pre( + &self, + request: &mut gloo_net::http::Request, + info: &OperationInfo, + ) -> std::result::Result<(), Error> { + Ok(()) + } + + /// Runs after completion of the request. + async fn post( + &self, + result: &Result, + info: &OperationInfo, + ) -> std::result::Result<(), Error> { + Ok(()) + } + + /// Execute the request. Note that for gloo-net, this is a simple wrapper + /// around the request's send method since there's no client object to manage. + async fn exec( + &self, + request: gloo_net::http::Request, + info: &OperationInfo, + ) -> Result { + request.send().await + } +} + +/// Wrapper around gloo_net::http::Headers to provide a nicer API. +#[derive(Debug)] +pub struct HeadersWrapper(gloo_net::http::Headers); + +impl HeadersWrapper { + /// Create a new HeadersWrapper from gloo_net::http::Headers. + pub fn from_gloo(headers: gloo_net::http::Headers) -> Self { + Self(headers) + } + + /// Get a header value by name. + pub fn get(&self, name: &str) -> Option { + self.0.get(name) + } + + /// Get the underlying gloo_net::http::Headers. + pub fn as_gloo(&self) -> &gloo_net::http::Headers { + &self.0 + } +} + +type InnerByteStream = Pin, JsValue>>>>; + +/// Untyped byte stream used for both success and error responses. +pub struct ByteStream(InnerByteStream); + +impl ByteStream { + /// Creates a new ByteStream + /// + /// Useful for generating test fixtures. + pub fn new(inner: InnerByteStream) -> Self { + Self(inner) + } + + /// Consumes the [`ByteStream`] and return its inner [`Stream`]. + pub fn into_inner(self) -> InnerByteStream { + self.0 + } +} + +impl Deref for ByteStream { + type Target = InnerByteStream; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for ByteStream { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +/// Typed value returned by generated client methods. +/// +/// This is used for successful responses and may appear in error responses +/// generated from the server (see [`Error::ErrorResponse`]) +pub struct ResponseValue { + inner: T, + status: u16, + headers: HeadersWrapper, +} + +impl ResponseValue { + #[doc(hidden)] + pub async fn from_response(response: gloo_net::http::Response) -> Result> { + let status = response.status(); + let headers = HeadersWrapper::from_gloo(response.headers()); + + let text = response + .text() + .await + .map_err(|e| Error::ResponseBodyError(format!("{:?}", e)))?; + + let inner = serde_json::from_str(&text) + .map_err(|e| Error::InvalidResponsePayload(text.into_bytes(), e))?; + + Ok(Self { + inner, + status, + headers, + }) + } +} + +impl ResponseValue<()> { + #[doc(hidden)] + pub fn empty(response: gloo_net::http::Response) -> Self { + let status = response.status(); + let headers = HeadersWrapper::from_gloo(response.headers()); + Self { + inner: (), + status, + headers, + } + } +} + +// Helper struct for empty stream +struct EmptyStream; + +impl Stream for EmptyStream { + type Item = Result, JsValue>; + + fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(None) + } +} + +// Helper to convert JsValue chunks to Vec +struct JsValueStream { + inner: wasm_streams::readable::IntoStream<'static>, +} + +impl Stream for JsValueStream { + type Item = Result, JsValue>; + + fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + match Pin::new(&mut self.inner).poll_next(cx) { + Poll::Ready(Some(Ok(js_value))) => { + // Convert JsValue to Uint8Array to Vec + match js_sys::Uint8Array::new(&js_value).to_vec().into() { + vec => Poll::Ready(Some(Ok(vec))), + } + } + Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))), + Poll::Ready(None) => Poll::Ready(None), + Poll::Pending => Poll::Pending, + } + } +} + +impl ResponseValue { + #[doc(hidden)] + pub fn stream(response: gloo_net::http::Response) -> Self { + let status = response.status(); + let headers = HeadersWrapper::from_gloo(response.headers()); + + // Convert web_sys::ReadableStream to futures::Stream + let stream: InnerByteStream = match response.body() { + Some(readable_stream) => { + let stream = wasm_streams::ReadableStream::from_raw(readable_stream); + Box::pin(JsValueStream { + inner: stream.into_stream(), + }) + } + None => { + // Empty stream + Box::pin(EmptyStream) + } + }; + + Self { + inner: ByteStream(stream), + status, + headers, + } + } +} + +impl ResponseValue { + #[doc(hidden)] + pub fn websocket(ws: web_sys::WebSocket) -> Result> { + // For WebSocket connections, we don't have traditional HTTP response status/headers + // since the WebSocket is created directly. We use a synthetic status of 101 + // (Switching Protocols) to indicate a successful upgrade. + Ok(Self { + inner: ws, + status: 101, + headers: HeadersWrapper::from_gloo(gloo_net::http::Headers::new()), + }) + } +} + +impl ResponseValue { + /// Creates a [`ResponseValue`] from the inner type, status, and headers. + /// + /// Useful for generating test fixtures. + pub fn new(inner: T, status: u16, headers: HeadersWrapper) -> Self { + Self { + inner, + status, + headers, + } + } + + /// Consumes the ResponseValue, returning the wrapped value. + pub fn into_inner(self) -> T { + self.inner + } + + /// Gets the status from this response. + pub fn status(&self) -> u16 { + self.status + } + + /// Gets the headers from this response. + pub fn headers(&self) -> &HeadersWrapper { + &self.headers + } + + /// Gets the parsed value of the Content-Length header, if present and + /// valid. + pub fn content_length(&self) -> Option { + self.headers + .get("content-length")? + .parse::() + .ok() + } + + #[doc(hidden)] + pub fn map(self, f: F) -> Result, E> + where + F: FnOnce(T) -> U, + { + let Self { + inner, + status, + headers, + } = self; + + Ok(ResponseValue { + inner: f(inner), + status, + headers, + }) + } +} + +impl ResponseValue { + /// Consumes the `ResponseValue`, returning the wrapped [`Stream`]. + pub fn into_inner_stream(self) -> InnerByteStream { + self.into_inner().into_inner() + } +} + +impl Deref for ResponseValue { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for ResponseValue { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +impl AsRef for ResponseValue { + fn as_ref(&self) -> &T { + &self.inner + } +} + +impl std::fmt::Debug for ResponseValue { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.inner.fmt(f) + } +} + +/// Error produced by generated client methods. +/// +/// The type parameter may be a struct if there's a single expected error type +/// or an enum if there are multiple valid error types. It can be the unit type +/// if there are no structured returns expected. +pub enum Error { + /// The request did not conform to API requirements. + InvalidRequest(String), + + /// A server error either due to the data, or with the connection. + CommunicationError(String), + + /// A documented, expected error response. + ErrorResponse(ResponseValue), + + /// Encountered an error reading the body for an expected response. + ResponseBodyError(String), + + /// An expected response code whose deserialization failed. + InvalidResponsePayload(Vec, serde_json::Error), + + /// A response not listed in the API description. This may represent a + /// success or failure response; check the status code. + UnexpectedResponse(gloo_net::http::Response), + + /// A custom error from a consumer-defined hook. + Custom(String), +} + +impl Error { + /// Returns the status code, if the error was generated from a response. + pub fn status(&self) -> Option { + match self { + Error::InvalidRequest(_) => None, + Error::Custom(_) => None, + Error::CommunicationError(_) => None, + Error::ErrorResponse(rv) => Some(rv.status()), + Error::ResponseBodyError(_) => None, + Error::InvalidResponsePayload(_, _) => None, + Error::UnexpectedResponse(r) => Some(r.status()), + } + } + + /// Converts this error into one without a typed body. + /// + /// This is useful for unified error handling with APIs that distinguish + /// various error response bodies. + pub fn into_untyped(self) -> Error { + match self { + Error::InvalidRequest(s) => Error::InvalidRequest(s), + Error::Custom(s) => Error::Custom(s), + Error::CommunicationError(s) => Error::CommunicationError(s), + Error::ErrorResponse(ResponseValue { + inner: _, + status, + headers, + }) => Error::ErrorResponse(ResponseValue { + inner: (), + status, + headers, + }), + Error::ResponseBodyError(s) => Error::ResponseBodyError(s), + Error::InvalidResponsePayload(b, e) => Error::InvalidResponsePayload(b, e), + Error::UnexpectedResponse(r) => Error::UnexpectedResponse(r), + } + } +} + +impl From for Error { + fn from(x: std::convert::Infallible) -> Self { + match x {} + } +} + +impl From for Error { + fn from(e: gloo_net::Error) -> Self { + Self::CommunicationError(format!("{:?}", e)) + } +} + +impl From for Error { + fn from(e: JsValue) -> Self { + Self::InvalidRequest(format!("{:?}", e)) + } +} + +impl std::fmt::Display for Error +where + ResponseValue: ErrorFormat, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::InvalidRequest(s) => { + write!(f, "Invalid Request: {}", s)?; + } + Error::CommunicationError(e) => { + write!(f, "Communication Error: {}", e)?; + } + Error::ErrorResponse(rve) => { + write!(f, "Error Response: ")?; + rve.fmt_info(f)?; + } + Error::ResponseBodyError(e) => { + write!(f, "Invalid Response Body: {}", e)?; + } + Error::InvalidResponsePayload(b, e) => { + write!( + f, + "Invalid Response Payload ({}): {}", + String::from_utf8_lossy(b), + e + )?; + } + Error::UnexpectedResponse(r) => { + write!(f, "Unexpected Response: status {}", r.status())?; + } + Error::Custom(s) => { + write!(f, "Error: {}", s)?; + } + } + + if f.alternate() { + use std::error::Error as _; + + let mut src = self.source().and_then(|e| e.source()); + while let Some(s) = src { + write!(f, ": {s}")?; + src = s.source(); + } + } + Ok(()) + } +} + +trait ErrorFormat { + fn fmt_info(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result; +} + +impl ErrorFormat for ResponseValue +where + E: std::fmt::Debug, +{ + fn fmt_info(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "status: {}; headers: {:?}; value: {:?}", + self.status, self.headers, self.inner, + ) + } +} + +impl ErrorFormat for ResponseValue { + fn fmt_info(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "status: {}; headers: {:?}; value: ", + self.status, self.headers, + ) + } +} + +impl std::fmt::Debug for Error +where + ResponseValue: ErrorFormat, +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self, f) + } +} + +impl std::error::Error for Error +where + ResponseValue: ErrorFormat, +{ + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::InvalidResponsePayload(_b, e) => Some(e), + _ => None, + } + } +} + +#[doc(hidden)] +pub trait RequestBuilderExt { + fn form_urlencoded( + self, + body: &T, + ) -> Result>; +} + +impl RequestBuilderExt for gloo_net::http::Request { + fn form_urlencoded( + self, + _body: &T, + ) -> Result> { + // form_urlencoded not supported in gloo-net + Err(Error::InvalidRequest( + "form_urlencoded is not supported as a post-construction operation in gloo-net".to_string() + )) + } +} + diff --git a/progenitor-client/src/lib.rs b/progenitor-client/src/lib.rs index f7ca0f66..1b778f80 100644 --- a/progenitor-client/src/lib.rs +++ b/progenitor-client/src/lib.rs @@ -4,15 +4,41 @@ #![deny(missing_docs)] -mod progenitor_client; +// Enforce mutual exclusivity of backend features +#[cfg(all(feature = "reqwest-client", feature = "gloo-client"))] +compile_error!("Cannot enable both reqwest-client and gloo-client features"); -pub use crate::progenitor_client::*; +#[cfg(not(any(feature = "reqwest-client", feature = "gloo-client")))] +compile_error!("Must enable either reqwest-client or gloo-client feature"); + +// Shared code used by both backends +mod shared; +pub use shared::*; + +// reqwest backend +#[cfg(feature = "reqwest-client")] +mod reqwest_impl; +#[cfg(feature = "reqwest-client")] +pub use reqwest_impl::*; + +// gloo-net backend +#[cfg(feature = "gloo-client")] +mod gloo_impl; +#[cfg(feature = "gloo-client")] +pub use gloo_impl::*; // For stand-alone crates, rather than adding a dependency on // progenitor-client, we simply dump the code right in. This means we don't // need to determine the provenance of progenitor (crates.io, github, etc.) // when generating the stand-alone crate. #[doc(hidden)] +#[cfg(feature = "reqwest-client")] +pub fn code() -> &'static str { + include_str!("reqwest_impl.rs") +} + +#[doc(hidden)] +#[cfg(feature = "gloo-client")] pub fn code() -> &'static str { - include_str!("progenitor_client.rs") + include_str!("gloo_impl.rs") } diff --git a/progenitor-client/src/progenitor_client.rs b/progenitor-client/src/reqwest_impl.rs similarity index 68% rename from progenitor-client/src/progenitor_client.rs rename to progenitor-client/src/reqwest_impl.rs index 6f8dcca0..35ea2c7a 100644 --- a/progenitor-client/src/progenitor_client.rs +++ b/progenitor-client/src/reqwest_impl.rs @@ -2,14 +2,16 @@ #![allow(dead_code)] -//! Support code for generated clients. +//! Support code for generated clients using reqwest. use std::ops::{Deref, DerefMut}; use bytes::Bytes; use futures_core::Stream; use reqwest::RequestBuilder; -use serde::{de::DeserializeOwned, ser::SerializeStruct, Serialize}; +use serde::{de::DeserializeOwned, Serialize}; + +use crate::OperationInfo; #[cfg(not(target_arch = "wasm32"))] type InnerByteStream = std::pin::Pin> + Send + Sync>>; @@ -87,11 +89,6 @@ where } } -/// Information about an operation, consumed by hook implementations. -pub struct OperationInfo { - /// The corresponding operationId from the source OpenAPI document. - pub operation_id: &'static str, -} /// Interface for changing the behavior of generated clients. All clients /// implement this for `&Client`; to override the default behavior, implement @@ -506,25 +503,6 @@ where } } -// See https://url.spec.whatwg.org/#url-path-segment-string -const PATH_SET: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS - .add(b' ') - .add(b'"') - .add(b'#') - .add(b'<') - .add(b'>') - .add(b'?') - .add(b'`') - .add(b'{') - .add(b'}') - .add(b'/') - .add(b'%'); - -#[doc(hidden)] -/// Percent encode input string. -pub fn encode_path(pc: &str) -> String { - percent_encoding::utf8_percent_encode(pc, PATH_SET).to_string() -} #[doc(hidden)] pub trait RequestBuilderExt { @@ -544,222 +522,3 @@ impl RequestBuilderExt for RequestBuilder { )) } } - -#[doc(hidden)] -pub struct QueryParam<'a, T> { - name: &'a str, - value: &'a T, -} - -impl<'a, T> QueryParam<'a, T> { - #[doc(hidden)] - pub fn new(name: &'a str, value: &'a T) -> Self { - Self { name, value } - } -} -impl Serialize for QueryParam<'_, T> -where - T: Serialize, -{ - fn serialize(&self, inner: S) -> Result - where - S: serde::Serializer, - { - let serializer = QuerySerializer { - inner, - name: self.name, - }; - self.value.serialize(serializer) - } -} - -pub(crate) struct QuerySerializer<'a, S> { - inner: S, - name: &'a str, -} - -macro_rules! serialize_scalar { - ($f:ident, $t:ty) => { - fn $f(self, v: $t) -> Result { - [(self.name, v)].serialize(self.inner) - } - }; -} - -impl<'a, S> serde::Serializer for QuerySerializer<'a, S> -where - S: serde::Serializer, -{ - type Ok = S::Ok; - type Error = S::Error; - type SerializeSeq = QuerySeq<'a, S::SerializeSeq>; - type SerializeTuple = S::SerializeTuple; - type SerializeTupleStruct = S::SerializeTupleStruct; - type SerializeTupleVariant = S::SerializeTupleVariant; - type SerializeMap = S::SerializeMap; - type SerializeStruct = S::SerializeStruct; - type SerializeStructVariant = S::SerializeStructVariant; - - serialize_scalar!(serialize_bool, bool); - serialize_scalar!(serialize_i8, i8); - serialize_scalar!(serialize_i16, i16); - serialize_scalar!(serialize_i32, i32); - serialize_scalar!(serialize_i64, i64); - serialize_scalar!(serialize_u8, u8); - serialize_scalar!(serialize_u16, u16); - serialize_scalar!(serialize_u32, u32); - serialize_scalar!(serialize_u64, u64); - serialize_scalar!(serialize_f32, f32); - serialize_scalar!(serialize_f64, f64); - serialize_scalar!(serialize_char, char); - serialize_scalar!(serialize_str, &str); - - fn serialize_bytes(self, v: &[u8]) -> Result { - self.inner.serialize_bytes(v) - } - - fn serialize_none(self) -> Result { - self.inner.serialize_none() - } - - fn serialize_some(self, value: &T) -> Result - where - T: ?Sized + Serialize, - { - // Serialize the value through self which will proxy into the inner - // Serializer as appropriate. - value.serialize(self) - } - - fn serialize_unit(self) -> Result { - self.inner.serialize_unit() - } - - fn serialize_unit_struct(self, name: &'static str) -> Result { - self.inner.serialize_unit_struct(name) - } - - fn serialize_unit_variant( - self, - _name: &'static str, - _variant_index: u32, - variant: &'static str, - ) -> Result { - // A query parameter with a list of enumerated values will produce an - // enum with unit variants. We treat these as scalar values, ignoring - // the unit variant wrapper. - variant.serialize(self) - } - - fn serialize_newtype_struct( - self, - name: &'static str, - value: &T, - ) -> Result - where - T: ?Sized + Serialize, - { - self.inner.serialize_newtype_struct(name, value) - } - - fn serialize_newtype_variant( - self, - name: &'static str, - _variant_index: u32, - variant: &'static str, - value: &T, - ) -> Result - where - T: ?Sized + Serialize, - { - // As with serde_json, we treat a newtype variant like a struct with a - // single field. This may seem a little weird, but if an OpenAPI - // document were to specify a query parameter whose schema was a oneOf - // whose elements were objects with a single field, the user would end - // up with an enum like this as a parameter. - let mut map = self.inner.serialize_struct(name, 1)?; - map.serialize_field(variant, value)?; - map.end() - } - - fn serialize_seq(self, len: Option) -> Result { - let Self { inner, name, .. } = self; - Ok(QuerySeq { - inner: inner.serialize_seq(len)?, - name, - }) - } - - fn serialize_tuple(self, len: usize) -> Result { - self.inner.serialize_tuple(len) - } - - fn serialize_tuple_struct( - self, - name: &'static str, - len: usize, - ) -> Result { - self.inner.serialize_tuple_struct(name, len) - } - - fn serialize_tuple_variant( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - len: usize, - ) -> Result { - self.inner - .serialize_tuple_variant(name, variant_index, variant, len) - } - - fn serialize_map(self, len: Option) -> Result { - self.inner.serialize_map(len) - } - - fn serialize_struct( - self, - name: &'static str, - len: usize, - ) -> Result { - self.inner.serialize_struct(name, len) - } - - fn serialize_struct_variant( - self, - name: &'static str, - variant_index: u32, - variant: &'static str, - len: usize, - ) -> Result { - self.inner - .serialize_struct_variant(name, variant_index, variant, len) - } -} - -#[doc(hidden)] -pub struct QuerySeq<'a, S> { - inner: S, - name: &'a str, -} - -impl serde::ser::SerializeSeq for QuerySeq<'_, S> -where - S: serde::ser::SerializeSeq, -{ - type Ok = S::Ok; - - type Error = S::Error; - - fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> - where - T: ?Sized + Serialize, - { - let v = (self.name, value); - self.inner.serialize_element(&v) - } - - fn end(self) -> Result { - self.inner.end() - } -} diff --git a/progenitor-client/src/shared.rs b/progenitor-client/src/shared.rs new file mode 100644 index 00000000..0183b9c0 --- /dev/null +++ b/progenitor-client/src/shared.rs @@ -0,0 +1,251 @@ +// Copyright 2025 Oxide Computer Company + +//! Shared code used by both reqwest and gloo-net backends. + +use serde::{ser::SerializeStruct, Serialize}; + +/// Information about an operation, consumed by hook implementations. +pub struct OperationInfo { + /// The corresponding operationId from the source OpenAPI document. + pub operation_id: &'static str, +} + +// See https://url.spec.whatwg.org/#url-path-segment-string +const PATH_SET: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS + .add(b' ') + .add(b'"') + .add(b'#') + .add(b'<') + .add(b'>') + .add(b'?') + .add(b'`') + .add(b'{') + .add(b'}') + .add(b'/') + .add(b'%'); + +#[doc(hidden)] +/// Percent encode input string. +pub fn encode_path(pc: &str) -> String { + percent_encoding::utf8_percent_encode(pc, PATH_SET).to_string() +} + +#[doc(hidden)] +pub struct QueryParam<'a, T> { + name: &'a str, + value: &'a T, +} + +impl<'a, T> QueryParam<'a, T> { + #[doc(hidden)] + pub fn new(name: &'a str, value: &'a T) -> Self { + Self { name, value } + } +} + +impl Serialize for QueryParam<'_, T> +where + T: Serialize, +{ + fn serialize(&self, inner: S) -> Result + where + S: serde::Serializer, + { + let serializer = QuerySerializer { + inner, + name: self.name, + }; + self.value.serialize(serializer) + } +} + +pub(crate) struct QuerySerializer<'a, S> { + inner: S, + name: &'a str, +} + +macro_rules! serialize_scalar { + ($f:ident, $t:ty) => { + fn $f(self, v: $t) -> Result { + [(self.name, v)].serialize(self.inner) + } + }; +} + +impl<'a, S> serde::Serializer for QuerySerializer<'a, S> +where + S: serde::Serializer, +{ + type Ok = S::Ok; + type Error = S::Error; + type SerializeSeq = QuerySeq<'a, S::SerializeSeq>; + type SerializeTuple = S::SerializeTuple; + type SerializeTupleStruct = S::SerializeTupleStruct; + type SerializeTupleVariant = S::SerializeTupleVariant; + type SerializeMap = S::SerializeMap; + type SerializeStruct = S::SerializeStruct; + type SerializeStructVariant = S::SerializeStructVariant; + + serialize_scalar!(serialize_bool, bool); + serialize_scalar!(serialize_i8, i8); + serialize_scalar!(serialize_i16, i16); + serialize_scalar!(serialize_i32, i32); + serialize_scalar!(serialize_i64, i64); + serialize_scalar!(serialize_u8, u8); + serialize_scalar!(serialize_u16, u16); + serialize_scalar!(serialize_u32, u32); + serialize_scalar!(serialize_u64, u64); + serialize_scalar!(serialize_f32, f32); + serialize_scalar!(serialize_f64, f64); + serialize_scalar!(serialize_char, char); + serialize_scalar!(serialize_str, &str); + + fn serialize_bytes(self, v: &[u8]) -> Result { + self.inner.serialize_bytes(v) + } + + fn serialize_none(self) -> Result { + self.inner.serialize_none() + } + + fn serialize_some(self, value: &T) -> Result + where + T: ?Sized + Serialize, + { + // Serialize the value through self which will proxy into the inner + // Serializer as appropriate. + value.serialize(self) + } + + fn serialize_unit(self) -> Result { + self.inner.serialize_unit() + } + + fn serialize_unit_struct(self, name: &'static str) -> Result { + self.inner.serialize_unit_struct(name) + } + + fn serialize_unit_variant( + self, + _name: &'static str, + _variant_index: u32, + variant: &'static str, + ) -> Result { + // A query parameter with a list of enumerated values will produce an + // enum with unit variants. We treat these as scalar values, ignoring + // the unit variant wrapper. + variant.serialize(self) + } + + fn serialize_newtype_struct( + self, + name: &'static str, + value: &T, + ) -> Result + where + T: ?Sized + Serialize, + { + self.inner.serialize_newtype_struct(name, value) + } + + fn serialize_newtype_variant( + self, + name: &'static str, + _variant_index: u32, + variant: &'static str, + value: &T, + ) -> Result + where + T: ?Sized + Serialize, + { + // As with serde_json, we treat a newtype variant like a struct with a + // single field. This may seem a little weird, but if an OpenAPI + // document were to specify a query parameter whose schema was a oneOf + // whose elements were objects with a single field, the user would end + // up with an enum like this as a parameter. + let mut map = self.inner.serialize_struct(name, 1)?; + map.serialize_field(variant, value)?; + map.end() + } + + fn serialize_seq(self, len: Option) -> Result { + let Self { inner, name, .. } = self; + Ok(QuerySeq { + inner: inner.serialize_seq(len)?, + name, + }) + } + + fn serialize_tuple(self, len: usize) -> Result { + self.inner.serialize_tuple(len) + } + + fn serialize_tuple_struct( + self, + name: &'static str, + len: usize, + ) -> Result { + self.inner.serialize_tuple_struct(name, len) + } + + fn serialize_tuple_variant( + self, + name: &'static str, + variant_index: u32, + variant: &'static str, + len: usize, + ) -> Result { + self.inner + .serialize_tuple_variant(name, variant_index, variant, len) + } + + fn serialize_map(self, len: Option) -> Result { + self.inner.serialize_map(len) + } + + fn serialize_struct( + self, + name: &'static str, + len: usize, + ) -> Result { + self.inner.serialize_struct(name, len) + } + + fn serialize_struct_variant( + self, + name: &'static str, + variant_index: u32, + variant: &'static str, + len: usize, + ) -> Result { + self.inner + .serialize_struct_variant(name, variant_index, variant, len) + } +} + +#[doc(hidden)] +pub struct QuerySeq<'a, S> { + inner: S, + name: &'a str, +} + +impl serde::ser::SerializeSeq for QuerySeq<'_, S> +where + S: serde::ser::SerializeSeq, +{ + type Ok = S::Ok; + + type Error = S::Error; + + fn serialize_element(&mut self, value: &T) -> Result<(), Self::Error> + where + T: ?Sized + Serialize, + { + let v = (self.name, value); + self.inner.serialize_element(&v) + } + + fn end(self) -> Result { + self.inner.end() + } +} diff --git a/progenitor-impl/Cargo.toml b/progenitor-impl/Cargo.toml index a9a04514..f909fd42 100644 --- a/progenitor-impl/Cargo.toml +++ b/progenitor-impl/Cargo.toml @@ -29,7 +29,7 @@ expectorate = { workspace = true } futures = { workspace = true } http = { workspace = true } hyper = { workspace = true } -progenitor-client = { workspace = true } +progenitor-client = { workspace = true, features = ["reqwest-client"] } reqwest = { workspace = true } rustfmt-wrapper = { workspace = true } semver = { workspace = true } diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 68454ece..4678c5ae 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -60,6 +60,7 @@ pub struct Generator { pub struct GenerationSettings { interface: InterfaceStyle, tag: TagStyle, + backend: HttpBackend, inner_type: Option, pre_hook: Option, pre_hook_async: Option, @@ -99,6 +100,21 @@ impl Default for InterfaceStyle { } } +/// HTTP backend for generated client. +#[derive(Clone, Deserialize, PartialEq, Eq, Debug)] +pub enum HttpBackend { + /// Use reqwest as the HTTP backend. + Reqwest, + /// Use gloo-net as the HTTP backend. + Gloo, +} + +impl Default for HttpBackend { + fn default() -> Self { + Self::Reqwest + } +} + /// Style for using the OpenAPI tags when generating names in the client. #[derive(Clone, Deserialize)] pub enum TagStyle { @@ -132,6 +148,12 @@ impl GenerationSettings { self } + /// Set the [HttpBackend]. + pub fn with_backend(&mut self, backend: HttpBackend) -> &mut Self { + self.backend = backend; + self + } + /// Client inner type available to pre and post hooks. pub fn with_inner_type(&mut self, inner_type: TokenStream) -> &mut Self { self.inner_type = Some(inner_type); @@ -415,6 +437,82 @@ impl Generator { let version_str = &spec.info.version; + let (client_field, client_impl, client_info_client_method) = match self.settings.backend { + HttpBackend::Reqwest => { + let field = quote! { + pub(crate) client: reqwest::Client, + }; + let impl_block = quote! { + /// Create a new client. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new( + baseurl: &str, + #inner_parameter + ) -> Self { + #[cfg(not(target_arch = "wasm32"))] + let client = { + let dur = ::std::time::Duration::from_secs(#client_timeout); + + reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + }; + + #[cfg(target_arch = "wasm32")] + let client = reqwest::ClientBuilder::new(); + + Self::new_with_client(baseurl, client.build().unwrap(), #inner_value) + } + + /// Construct a new client with an existing `reqwest::Client`, + /// allowing more control over its configuration. + /// + /// `baseurl` is the base URL provided to the internal + /// `reqwest::Client`, and should include a scheme and hostname, + /// as well as port and a path stem if applicable. + pub fn new_with_client( + baseurl: &str, + client: reqwest::Client, + #inner_parameter + ) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + #inner_value + } + } + }; + let client_method = quote! { + fn client(&self) -> &reqwest::Client { + &self.client + } + }; + (field, impl_block, client_method) + } + HttpBackend::Gloo => { + let field = quote! {}; + let impl_block = quote! { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new( + baseurl: &str, + #inner_parameter + ) -> Self { + Self { + baseurl: baseurl.to_string(), + #inner_value + } + } + }; + let client_method = quote! {}; + (field, impl_block, client_method) + } + }; + // The allow(unused_imports) on the `pub use` is necessary with Rust // 1.76+, in case the generated file is not at the top level of the // crate. @@ -446,52 +544,12 @@ impl Generator { #[doc = #client_docstring] pub struct Client { pub(crate) baseurl: String, - pub(crate) client: reqwest::Client, + #client_field #inner_property } impl Client { - /// Create a new client. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new( - baseurl: &str, - #inner_parameter - ) -> Self { - #[cfg(not(target_arch = "wasm32"))] - let client = { - let dur = ::std::time::Duration::from_secs(#client_timeout); - - reqwest::ClientBuilder::new() - .connect_timeout(dur) - .timeout(dur) - }; - - #[cfg(target_arch = "wasm32")] - let client = reqwest::ClientBuilder::new(); - - Self::new_with_client(baseurl, client.build().unwrap(), #inner_value) - } - - /// Construct a new client with an existing `reqwest::Client`, - /// allowing more control over its configuration. - /// - /// `baseurl` is the base URL provided to the internal - /// `reqwest::Client`, and should include a scheme and hostname, - /// as well as port and a path stem if applicable. - pub fn new_with_client( - baseurl: &str, - client: reqwest::Client, - #inner_parameter - ) -> Self { - Self { - baseurl: baseurl.to_string(), - client, - #inner_value - } - } + #client_impl } impl ClientInfo<#inner_type> for Client { @@ -503,9 +561,7 @@ impl Generator { self.baseurl.as_str() } - fn client(&self) -> &reqwest::Client { - &self.client - } + #client_info_client_method fn inner(&self) -> &#inner_type { #inner_fn_value diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index 8bf1d0fe..80bc9e7d 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -14,7 +14,7 @@ use typify::{TypeId, TypeSpace}; use crate::{ template::PathTemplate, util::{items, parameter_map, sanitize, unique_ident_from, Case}, - Error, Generator, Result, TagStyle, + Error, Generator, HttpBackend, Result, TagStyle, }; use crate::{to_schema::ToSchema, util::ReferenceOrExt}; @@ -263,7 +263,7 @@ pub(crate) enum OperationResponseKind { } impl OperationResponseKind { - pub fn into_tokens(self, type_space: &TypeSpace) -> TokenStream { + pub fn into_tokens(self, type_space: &TypeSpace, backend: &crate::HttpBackend) -> TokenStream { match self { OperationResponseKind::Type(ref type_id) => { let type_name = type_space.get_type(type_id).unwrap().ident(); @@ -276,7 +276,10 @@ impl OperationResponseKind { quote! { ByteStream } } OperationResponseKind::Upgrade => { - quote! { reqwest::Upgraded } + match backend { + crate::HttpBackend::Reqwest => quote! { reqwest::Upgraded }, + crate::HttpBackend::Gloo => quote! { web_sys::WebSocket }, + } } } } @@ -598,7 +601,10 @@ impl Generator { }); let bounds = if raw_body_param { - quote! { <'a, B: Into > } + match self.settings.backend { + HttpBackend::Reqwest => quote! { <'a, B: Into > }, + HttpBackend::Gloo => quote! { <'a, B: Into<::wasm_bindgen::JsValue> > }, + } } else { quote! { <'a> } }; @@ -624,6 +630,12 @@ impl Generator { } }; + // For WASM, use .boxed_local() instead of .boxed() since Send is not available + let boxed_method = match self.settings.backend { + HttpBackend::Reqwest => quote! { .boxed() }, + HttpBackend::Gloo => quote! { .boxed_local() }, + }; + let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { // We're now using futures. self.uses_futures = true; @@ -747,7 +759,7 @@ impl Generator { first.chain(rest) }) .try_flatten_stream() - .boxed() + #boxed_method } } }); @@ -790,9 +802,26 @@ impl Generator { OperationParameterKind::Query(_) => { let qn = ¶m.api_name; let qn_ident = format_ident!("{}", ¶m.name); - Some(quote! { - &progenitor_client::QueryParam::new(#qn, &#qn_ident) - }) + + match self.settings.backend { + HttpBackend::Reqwest => { + Some(quote! { + &progenitor_client::QueryParam::new(#qn, &#qn_ident) + }) + } + HttpBackend::Gloo => { + // Serialize to URL-encoded format and parse into (key, value) pairs + Some(quote! { + ::serde_urlencoded::to_string([(#qn, &#qn_ident)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }) + }) + } + } } _ => None, }) @@ -828,22 +857,34 @@ impl Generator { }) .collect::>(); - let headers_size = headers.len() + 1; - let headers_build = quote! { - let mut header_map = ::reqwest::header::HeaderMap::with_capacity(#headers_size); - header_map.append( - ::reqwest::header::HeaderName::from_static("api-version"), - ::reqwest::header::HeaderValue::from_static(#client_type::api_version()), - ); - - #(#headers)* - }; - - let headers_use = quote! { - .headers(header_map) + let (headers_build, headers_use) = match self.settings.backend { + HttpBackend::Reqwest => { + let headers_size = headers.len() + 1; + let build = quote! { + let mut header_map = ::reqwest::header::HeaderMap::with_capacity(#headers_size); + header_map.append( + ::reqwest::header::HeaderName::from_static("api-version"), + ::reqwest::header::HeaderValue::from_static(#client_type::api_version()), + ); + + #(#headers)* + }; + let use_stmt = quote! { + .headers(header_map) + }; + (build, use_stmt) + } + HttpBackend::Gloo => { + // All headers are set directly on the request builder. + let build = quote! {}; + let use_stmt = quote! { + .header("api-version", #client_type::api_version()) + }; + (build, use_stmt) + } }; - let websock_hdrs = if method.dropshot_websocket { + let websock_hdrs = if method.dropshot_websocket && matches!(self.settings.backend, HttpBackend::Reqwest) { quote! { .header(::reqwest::header::CONNECTION, "Upgrade") .header(::reqwest::header::UPGRADE, "websocket") @@ -882,42 +923,64 @@ impl Generator { ( OperationParameterKind::Body(BodyContentType::OctetStream), OperationParameterType::RawBody, - ) => Some(quote! { - // Set the content type (this is handled by helper - // functions for other MIME types). - .header( - ::reqwest::header::CONTENT_TYPE, - ::reqwest::header::HeaderValue::from_static("application/octet-stream"), - ) - .body(body) - }), + ) => match self.settings.backend { + HttpBackend::Reqwest => Some(quote! { + .header( + ::reqwest::header::CONTENT_TYPE, + ::reqwest::header::HeaderValue::from_static("application/octet-stream"), + ) + .body(body) + }), + HttpBackend::Gloo => Some(quote! { + .header("content-type", "application/octet-stream") + .body(body)? + }), + }, ( OperationParameterKind::Body(BodyContentType::Text(mime_type)), OperationParameterType::RawBody, - ) => Some(quote! { - // Set the content type (this is handled by helper - // functions for other MIME types). - .header( - ::reqwest::header::CONTENT_TYPE, - ::reqwest::header::HeaderValue::from_static(#mime_type), - ) - .body(body) - }), + ) => match self.settings.backend { + HttpBackend::Reqwest => Some(quote! { + .header( + ::reqwest::header::CONTENT_TYPE, + ::reqwest::header::HeaderValue::from_static(#mime_type), + ) + .body(body) + }), + HttpBackend::Gloo => Some(quote! { + .header("content-type", #mime_type) + .body(body)? + }), + }, ( OperationParameterKind::Body(BodyContentType::Json), OperationParameterType::Type(_), - ) => Some(quote! { - // Serialization errors are deferred. - .json(&body) - }), + ) => match self.settings.backend { + HttpBackend::Reqwest => Some(quote! { + .json(&body) + }), + HttpBackend::Gloo => Some(quote! { + .json(&body)? + }), + }, ( OperationParameterKind::Body(BodyContentType::FormUrlencoded), OperationParameterType::Type(_), - ) => Some(quote! { - // This uses progenitor_client::RequestBuilderExt which - // returns an error in the case of a serialization failure. - .form_urlencoded(&body)? - }), + ) => match self.settings.backend { + HttpBackend::Reqwest => Some(quote! { + // This uses progenitor_client::RequestBuilderExt which + // returns an error in the case of a serialization failure. + .form_urlencoded(&body)? + }), + HttpBackend::Gloo => { + // For gloo-net, form-urlencoded must be handled during request construction + Some(quote! { + .header("content-type", "application/x-www-form-urlencoded") + .body(::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?)? + }) + } + }, (OperationParameterKind::Body(_), _) => { unreachable!("invalid body kind/type combination") } @@ -927,6 +990,14 @@ impl Generator { // ... and there can be at most one body. assert!(body_func.clone().count() <= 1); + // .json() and .body() return Request, only call .build() without body + let has_body = body_func.clone().count() > 0; + let gloo_build_call = if has_body { + quote! {} + } else { + quote! { .build()? } + }; + let (success_response_items, response_type) = self.extract_responses(method, OperationResponseStatus::is_success_or_default); @@ -1028,13 +1099,18 @@ impl Generator { | (OperationResponseKind::None, OperationResponseKind::Type(_)) ) .then(|| { - quote! { + match self.settings.backend { + HttpBackend::Reqwest => quote! { .header( ::reqwest::header::ACCEPT, ::reqwest::header::HeaderValue::from_static( "application/json", ), ) + }, + HttpBackend::Gloo => quote! { + .header("accept", "application/json") + }, } }); @@ -1085,44 +1161,97 @@ impl Generator { let operation_id = &method.operation_id; let method_func = format_ident!("{}", method.method.as_str()); - let body_impl = quote! { - #url_path + let request_build = match self.settings.backend { + HttpBackend::Reqwest => quote! { + #[allow(unused_mut)] + let mut #request_ident = #client_value.client + . #method_func (#url_ident) + #accept_header + #(#body_func)* + #( .query(#query_params) )* + #headers_use + #websock_hdrs + .build()?; + + let info = OperationInfo { + operation_id: #operation_id, + }; - #headers_build + #pre_hook + #pre_hook_async + #client_value + .pre(&mut #request_ident, &info) + .await?; - #[allow(unused_mut)] - let mut #request_ident = #client_value.client - . #method_func (#url_ident) - #accept_header - #(#body_func)* - #( .query(#query_params) )* - #headers_use - #websock_hdrs - .build()?; + let #result_ident = #client_value + .exec(#request_ident, &info) + .await; + }, + HttpBackend::Gloo => { + // WebSocket handling is done in body_impl + quote! { + let #request_ident = ::gloo_net::http::Request::#method_func(&#url_ident) + #accept_header + #( .query(#query_params) )* + #headers_use + #(#body_func)* + #gloo_build_call; + + let info = OperationInfo { + operation_id: #operation_id, + }; - let info = OperationInfo { - operation_id: #operation_id, - }; + // pre-hook with &mut request not supported for gloo-net + // since Request is immutable + #pre_hook + #pre_hook_async + + let #result_ident = #client_value + .exec(#request_ident, &info) + .await; + } + }, + }; - #pre_hook - #pre_hook_async - #client_value - .pre(&mut #request_ident, &info) - .await?; + // Status code extraction + let status_conversion = match self.settings.backend { + HttpBackend::Reqwest => quote! { .as_u16() }, + HttpBackend::Gloo => quote! {}, // gloo-net already returns u16 + }; + + let body_impl = if method.dropshot_websocket && matches!(self.settings.backend, HttpBackend::Gloo) { + // Create WebSocket directly + quote! { + #url_path - let #result_ident = #client_value - .exec(#request_ident, &info) - .await; + // Convert HTTP(S) URL to WS(S) URL + let ws_url = #url_ident + .replace("https://", "wss://") + .replace("http://", "ws://"); - #client_value - .post(&#result_ident, &info) - .await?; - #post_hook_async - #post_hook + // Create WebSocket connection + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + + ResponseValue::websocket(ws) + } + } else { + quote! { + #url_path - let #response_ident = #result_ident?; + #headers_build - match #response_ident.status().as_u16() { + #request_build + + #client_value + .post(&#result_ident, &info) + .await?; + #post_hook_async + #post_hook + + let #response_ident = #result_ident?; + + match #response_ident.status()#status_conversion { // These will be of the form... // 201 => ResponseValue::from_response(response).await, // 200..299 => ResponseValue::empty(response), @@ -1150,17 +1279,18 @@ impl Generator { // } #(#error_response_matches)* - // The default response is either an Error with a known - // type if the operation defines a default (as above) or - // an Error::UnexpectedResponse... - // _ => Err(Error::UnexpectedResponse(response)), - #default_response + // The default response is either an Error with a known + // type if the operation defines a default (as above) or + // an Error::UnexpectedResponse... + // _ => Err(Error::UnexpectedResponse(response)), + #default_response + } } }; Ok(MethodSigBody { - success: response_type.into_tokens(&self.type_space), - error: error_type.into_tokens(&self.type_space), + success: response_type.into_tokens(&self.type_space, &self.settings.backend), + error: error_type.into_tokens(&self.type_space, &self.settings.backend), body: body_impl, }) } @@ -1456,7 +1586,10 @@ impl Generator { OperationParameterType::RawBody => { cloneable = false; - Ok(quote! { Result }) + match self.settings.backend { + HttpBackend::Reqwest => Ok(quote! { Result }), + HttpBackend::Gloo => Ok(quote! { Result<::wasm_bindgen::JsValue, String> }), + } } }) .collect::>>()?; @@ -1614,18 +1747,36 @@ impl Generator { OperationParameterType::RawBody => match param.kind { OperationParameterKind::Body(BodyContentType::OctetStream) => { - let err_msg = - format!("conversion to `reqwest::Body` for {} failed", param.name,); - - Ok(quote! { - pub fn #param_name(mut self, value: B) -> Self - where B: std::convert::TryInto - { - self.#param_name = value.try_into() - .map_err(|_| #err_msg.to_string()); - self + match self.settings.backend { + HttpBackend::Reqwest => { + let err_msg = + format!("conversion to `reqwest::Body` for {} failed", param.name,); + + Ok(quote! { + pub fn #param_name(mut self, value: B) -> Self + where B: std::convert::TryInto + { + self.#param_name = value.try_into() + .map_err(|_| #err_msg.to_string()); + self + } + }) } - }) + HttpBackend::Gloo => { + let err_msg = + format!("conversion to `wasm_bindgen::JsValue` for {} failed", param.name,); + + Ok(quote! { + pub fn #param_name(mut self, value: B) -> Self + where B: std::convert::TryInto<::wasm_bindgen::JsValue> + { + self.#param_name = value.try_into() + .map_err(|_| #err_msg.to_string()); + self + } + }) + } + } } OperationParameterKind::Body(BodyContentType::Text(_)) => { let err_msg = @@ -1695,6 +1846,12 @@ impl Generator { } }; + // For WASM, use .boxed_local() instead of .boxed() since Send is not available + let boxed_method = match self.settings.backend { + HttpBackend::Reqwest => quote! { .boxed() }, + HttpBackend::Gloo => quote! { .boxed_local() }, + }; + let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { // We're now using futures. self.uses_futures = true; @@ -1791,7 +1948,7 @@ impl Generator { first.chain(rest) }) .try_flatten_stream() - .boxed() + #boxed_method } } }); diff --git a/progenitor-impl/tests/output/Cargo.toml b/progenitor-impl/tests/output/Cargo.toml index 18a71439..dbec1e99 100644 --- a/progenitor-impl/tests/output/Cargo.toml +++ b/progenitor-impl/tests/output/Cargo.toml @@ -9,19 +9,33 @@ edition = "2021" anyhow = "1.0" base64 = "0.21" chrono = { version = "0.4", features = ["serde"] } -clap = { version = "4", features = ["string"] } futures = "0.3" -httpmock = "0.7" -progenitor-client = { path = "../../../progenitor-client" } rand = { version = "0.8", features = ["serde1"] } regex = "1.10" regress = "0.7" -reqwest = "0.12" schemars = { version = "0.8", features = ["chrono", "uuid1"] } serde = { features = ["derive"], version = "1" } serde_json = "1" +serde_urlencoded = "0.7" uuid = { features = ["serde", "v4"], version = "1" } +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +progenitor-client = { path = "../../../progenitor-client", features = ["reqwest-client"] } +clap = { version = "4", features = ["string"] } +httpmock = "0.7" +reqwest = "0.12" + +# rand/uuid transitively depend on getrandom, which requires the "js" feature +# to work on wasm32-unknown-unknown targets +[target.'cfg(target_arch = "wasm32")'.dependencies] +progenitor-client = { path = "../../../progenitor-client", features = ["gloo-client"] } +getrandom = { version = "0.2", features = ["js"] } +uuid = { version = "1", features = ["serde", "v4", "js"] } +gloo-net = "0.6" +js-sys = "0.3" +wasm-bindgen = "0.2" +web-sys = { version = "0.3", features = ["WebSocket"] } + [lints.rust] unused_imports = "allow" unused_variables = "allow" diff --git a/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder.rs new file mode 100644 index 00000000..0d50a904 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder.rs @@ -0,0 +1,3922 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`GetThingOrThingsId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string" + /// }, + /// { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(untagged)] + pub enum GetThingOrThingsId { + String(::std::string::String), + Array(::std::vec::Vec<::std::string::String>), + } + + impl ::std::convert::From<&Self> for GetThingOrThingsId { + fn from(value: &GetThingOrThingsId) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for GetThingOrThingsId { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self::Array(value) + } + } + + ///`HeaderArgAcceptLanguage` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "default": "en", + /// "type": "string", + /// "enum": [ + /// "de", + /// "en" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum HeaderArgAcceptLanguage { + #[serde(rename = "de")] + De, + #[serde(rename = "en")] + En, + } + + impl ::std::convert::From<&Self> for HeaderArgAcceptLanguage { + fn from(value: &HeaderArgAcceptLanguage) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for HeaderArgAcceptLanguage { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::De => f.write_str("de"), + Self::En => f.write_str("en"), + } + } + } + + impl ::std::str::FromStr for HeaderArgAcceptLanguage { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "de" => Ok(Self::De), + "en" => Ok(Self::En), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::default::Default for HeaderArgAcceptLanguage { + fn default() -> Self { + HeaderArgAcceptLanguage::En + } + } + + ///`ObjWithOptionArray` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "stranger-things", + /// "things" + /// ], + /// "properties": { + /// "stranger-things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ], + /// "oneOf": [ + /// {} + /// ] + /// } + /// ] + /// } + /// }, + /// "things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ] + /// } + /// ] + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ObjWithOptionArray { + #[serde(rename = "stranger-things")] + pub stranger_things: ::std::vec::Vec<::std::option::Option>, + pub things: ::std::vec::Vec<::std::option::Option>, + } + + impl ::std::convert::From<&ObjWithOptionArray> for ObjWithOptionArray { + fn from(value: &ObjWithOptionArray) -> Self { + value.clone() + } + } + + impl ObjWithOptionArray { + pub fn builder() -> builder::ObjWithOptionArray { + Default::default() + } + } + + ///`Task` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "output_rules", + /// "script", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "state": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Task { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + pub state: ::std::string::String, + } + + impl ::std::convert::From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() + } + } + + impl Task { + pub fn builder() -> builder::Task { + Default::default() + } + } + + ///`TaskEvent` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "seq", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "seq": { + /// "type": "integer", + /// "format": "uint", + /// "minimum": 0.0 + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TaskEvent { + pub payload: ::std::string::String, + pub seq: u32, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&TaskEvent> for TaskEvent { + fn from(value: &TaskEvent) -> Self { + value.clone() + } + } + + impl TaskEvent { + pub fn builder() -> builder::TaskEvent { + Default::default() + } + } + + ///`TaskOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TaskOutput { + pub id: ::std::string::String, + pub path: ::std::string::String, + pub size: u64, + } + + impl ::std::convert::From<&TaskOutput> for TaskOutput { + fn from(value: &TaskOutput) -> Self { + value.clone() + } + } + + impl TaskOutput { + pub fn builder() -> builder::TaskOutput { + Default::default() + } + } + + ///`TaskSubmit` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "default", + /// "name", + /// "script" + /// ], + /// "properties": { + /// "default": { + /// "type": "boolean" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TaskSubmit { + pub default: bool, + pub name: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() + } + } + + impl TaskSubmit { + pub fn builder() -> builder::TaskSubmit { + Default::default() + } + } + + ///`TaskSubmitResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TaskSubmitResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmitResult> for TaskSubmitResult { + fn from(value: &TaskSubmitResult) -> Self { + value.clone() + } + } + + impl TaskSubmitResult { + pub fn builder() -> builder::TaskSubmitResult { + Default::default() + } + } + + ///`UploadedChunk` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UploadedChunk { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() + } + } + + impl UploadedChunk { + pub fn builder() -> builder::UploadedChunk { + Default::default() + } + } + + ///`UserCreate` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserCreate { + pub name: ::std::string::String, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + Default::default() + } + } + + ///`UserCreateResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "token" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserCreateResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + impl UserCreateResult { + pub fn builder() -> builder::UserCreateResult { + Default::default() + } + } + + ///`WhoamiResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WhoamiResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + impl WhoamiResult { + pub fn builder() -> builder::WhoamiResult { + Default::default() + } + } + + ///`Worker` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "deleted", + /// "id", + /// "recycle", + /// "tasks" + /// ], + /// "properties": { + /// "deleted": { + /// "type": "boolean" + /// }, + /// "id": { + /// "type": "string" + /// }, + /// "instance_id": { + /// "type": "string" + /// }, + /// "lastping": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "recycle": { + /// "type": "boolean" + /// }, + /// "tasks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/WorkerTask" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Worker { + pub deleted: bool, + pub id: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub instance_id: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub lastping: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + pub recycle: bool, + pub tasks: ::std::vec::Vec, + } + + impl ::std::convert::From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + impl Worker { + pub fn builder() -> builder::Worker { + Default::default() + } + } + + ///`WorkerAddOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "chunks", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "chunks": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerAddOutput { + pub chunks: ::std::vec::Vec<::std::string::String>, + pub path: ::std::string::String, + pub size: i64, + } + + impl ::std::convert::From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + impl WorkerAddOutput { + pub fn builder() -> builder::WorkerAddOutput { + Default::default() + } + } + + ///`WorkerAppendTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerAppendTask { + pub payload: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&WorkerAppendTask> for WorkerAppendTask { + fn from(value: &WorkerAppendTask) -> Self { + value.clone() + } + } + + impl WorkerAppendTask { + pub fn builder() -> builder::WorkerAppendTask { + Default::default() + } + } + + ///`WorkerBootstrap` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootstrap", + /// "token" + /// ], + /// "properties": { + /// "bootstrap": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerBootstrap { + pub bootstrap: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + impl WorkerBootstrap { + pub fn builder() -> builder::WorkerBootstrap { + Default::default() + } + } + + ///`WorkerBootstrapResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerBootstrapResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + impl WorkerBootstrapResult { + pub fn builder() -> builder::WorkerBootstrapResult { + Default::default() + } + } + + ///`WorkerCompleteTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "failed" + /// ], + /// "properties": { + /// "failed": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl ::std::convert::From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + impl WorkerCompleteTask { + pub fn builder() -> builder::WorkerCompleteTask { + Default::default() + } + } + + ///`WorkerPingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "poweroff" + /// ], + /// "properties": { + /// "poweroff": { + /// "type": "boolean" + /// }, + /// "task": { + /// "$ref": "#/components/schemas/WorkerPingTask" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerPingResult { + pub poweroff: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + } + + impl ::std::convert::From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + impl WorkerPingResult { + pub fn builder() -> builder::WorkerPingResult { + Default::default() + } + } + + ///`WorkerPingTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "output_rules", + /// "script" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerPingTask { + pub id: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + impl WorkerPingTask { + pub fn builder() -> builder::WorkerPingTask { + Default::default() + } + } + + ///`WorkerTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "owner" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "owner": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkerTask { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub owner: ::std::string::String, + } + + impl ::std::convert::From<&WorkerTask> for WorkerTask { + fn from(value: &WorkerTask) -> Self { + value.clone() + } + } + + impl WorkerTask { + pub fn builder() -> builder::WorkerTask { + Default::default() + } + } + + ///`WorkersResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "workers" + /// ], + /// "properties": { + /// "workers": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Worker" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct WorkersResult { + pub workers: ::std::vec::Vec, + } + + impl ::std::convert::From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } + + impl WorkersResult { + pub fn builder() -> builder::WorkersResult { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct ObjWithOptionArray { + stranger_things: ::std::result::Result< + ::std::vec::Vec<::std::option::Option>, + ::std::string::String, + >, + things: ::std::result::Result< + ::std::vec::Vec<::std::option::Option>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ObjWithOptionArray { + fn default() -> Self { + Self { + stranger_things: Err("no value supplied for stranger_things".to_string()), + things: Err("no value supplied for things".to_string()), + } + } + } + + impl ObjWithOptionArray { + pub fn stranger_things(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::option::Option>>, + T::Error: ::std::fmt::Display, + { + self.stranger_things = value.try_into().map_err(|e| { + format!("error converting supplied value for stranger_things: {}", e) + }); + self + } + pub fn things(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::option::Option>>, + T::Error: ::std::fmt::Display, + { + self.things = value + .try_into() + .map_err(|e| format!("error converting supplied value for things: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ObjWithOptionArray { + type Error = super::error::ConversionError; + fn try_from( + value: ObjWithOptionArray, + ) -> ::std::result::Result { + Ok(Self { + stranger_things: value.stranger_things?, + things: value.things?, + }) + } + } + + impl ::std::convert::From for ObjWithOptionArray { + fn from(value: super::ObjWithOptionArray) -> Self { + Self { + stranger_things: Ok(value.stranger_things), + things: Ok(value.things), + } + } + } + + #[derive(Clone, Debug)] + pub struct Task { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + state: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Task { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + script: Err("no value supplied for script".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Task { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Task { + type Error = super::error::ConversionError; + fn try_from(value: Task) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + output_rules: value.output_rules?, + script: value.script?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Task { + fn from(value: super::Task) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskEvent { + payload: ::std::result::Result<::std::string::String, ::std::string::String>, + seq: ::std::result::Result, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for TaskEvent { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + seq: Err("no value supplied for seq".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl TaskEvent { + pub fn payload(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn seq(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.seq = value + .try_into() + .map_err(|e| format!("error converting supplied value for seq: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskEvent { + type Error = super::error::ConversionError; + fn try_from( + value: TaskEvent, + ) -> ::std::result::Result { + Ok(Self { + payload: value.payload?, + seq: value.seq?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for TaskEvent { + fn from(value: super::TaskEvent) -> Self { + Self { + payload: Ok(value.payload), + seq: Ok(value.seq), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskOutput { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + path: ::std::result::Result<::std::string::String, ::std::string::String>, + size: ::std::result::Result, + } + + impl ::std::default::Default for TaskOutput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl TaskOutput { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskOutput { + type Error = super::error::ConversionError; + fn try_from( + value: TaskOutput, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for TaskOutput { + fn from(value: super::TaskOutput) -> Self { + Self { + id: Ok(value.id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmit { + default: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for TaskSubmit { + fn default() -> Self { + Self { + default: Err("no value supplied for default".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Ok(Default::default()), + script: Err("no value supplied for script".to_string()), + } + } + } + + impl TaskSubmit { + pub fn default(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.default = value + .try_into() + .map_err(|e| format!("error converting supplied value for default: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskSubmit { + type Error = super::error::ConversionError; + fn try_from( + value: TaskSubmit, + ) -> ::std::result::Result { + Ok(Self { + default: value.default?, + name: value.name?, + output_rules: value.output_rules?, + script: value.script?, + }) + } + } + + impl ::std::convert::From for TaskSubmit { + fn from(value: super::TaskSubmit) -> Self { + Self { + default: Ok(value.default), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmitResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for TaskSubmitResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl TaskSubmitResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskSubmitResult { + type Error = super::error::ConversionError; + fn try_from( + value: TaskSubmitResult, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for TaskSubmitResult { + fn from(value: super::TaskSubmitResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct UploadedChunk { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UploadedChunk { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl UploadedChunk { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UploadedChunk { + type Error = super::error::ConversionError; + fn try_from( + value: UploadedChunk, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for UploadedChunk { + fn from(value: super::UploadedChunk) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UserCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl UserCreate { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreate { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreate, + ) -> ::std::result::Result { + Ok(Self { name: value.name? }) + } + } + + impl ::std::convert::From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreateResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + token: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UserCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl UserCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreateResult { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreateResult, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl ::std::convert::From for UserCreateResult { + fn from(value: super::UserCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WhoamiResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WhoamiResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WhoamiResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WhoamiResult { + type Error = super::error::ConversionError; + fn try_from( + value: WhoamiResult, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for WhoamiResult { + fn from(value: super::WhoamiResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Worker { + deleted: ::std::result::Result, + id: ::std::result::Result<::std::string::String, ::std::string::String>, + instance_id: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + lastping: ::std::result::Result< + ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + ::std::string::String, + >, + recycle: ::std::result::Result, + tasks: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for Worker { + fn default() -> Self { + Self { + deleted: Err("no value supplied for deleted".to_string()), + id: Err("no value supplied for id".to_string()), + instance_id: Ok(Default::default()), + lastping: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl Worker { + pub fn deleted(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.deleted = value + .try_into() + .map_err(|e| format!("error converting supplied value for deleted: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn instance_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.instance_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); + self + } + pub fn lastping(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + >, + T::Error: ::std::fmt::Display, + { + self.lastping = value + .try_into() + .map_err(|e| format!("error converting supplied value for lastping: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Worker { + type Error = super::error::ConversionError; + fn try_from( + value: Worker, + ) -> ::std::result::Result { + Ok(Self { + deleted: value.deleted?, + id: value.id?, + instance_id: value.instance_id?, + lastping: value.lastping?, + recycle: value.recycle?, + tasks: value.tasks?, + }) + } + } + + impl ::std::convert::From for Worker { + fn from(value: super::Worker) -> Self { + Self { + deleted: Ok(value.deleted), + id: Ok(value.id), + instance_id: Ok(value.instance_id), + lastping: Ok(value.lastping), + recycle: Ok(value.recycle), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutput { + chunks: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + path: ::std::result::Result<::std::string::String, ::std::string::String>, + size: ::std::result::Result, + } + + impl ::std::default::Default for WorkerAddOutput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl WorkerAddOutput { + pub fn chunks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerAddOutput { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerAddOutput, + ) -> ::std::result::Result { + Ok(Self { + chunks: value.chunks?, + path: value.path?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for WorkerAddOutput { + fn from(value: super::WorkerAddOutput) -> Self { + Self { + chunks: Ok(value.chunks), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendTask { + payload: ::std::result::Result<::std::string::String, ::std::string::String>, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for WorkerAppendTask { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendTask { + pub fn payload(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerAppendTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerAppendTask, + ) -> ::std::result::Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for WorkerAppendTask { + fn from(value: super::WorkerAppendTask) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrap { + bootstrap: ::std::result::Result<::std::string::String, ::std::string::String>, + token: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerBootstrap { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl WorkerBootstrap { + pub fn bootstrap(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerBootstrap { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrap, + ) -> ::std::result::Result { + Ok(Self { + bootstrap: value.bootstrap?, + token: value.token?, + }) + } + } + + impl ::std::convert::From for WorkerBootstrap { + fn from(value: super::WorkerBootstrap) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrapResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerBootstrapResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl WorkerBootstrapResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerBootstrapResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrapResult, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for WorkerBootstrapResult { + fn from(value: super::WorkerBootstrapResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteTask { + failed: ::std::result::Result, + } + + impl ::std::default::Default for WorkerCompleteTask { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteTask { + pub fn failed(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerCompleteTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerCompleteTask, + ) -> ::std::result::Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl ::std::convert::From for WorkerCompleteTask { + fn from(value: super::WorkerCompleteTask) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingResult { + poweroff: ::std::result::Result, + task: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + } + + impl ::std::default::Default for WorkerPingResult { + fn default() -> Self { + Self { + poweroff: Err("no value supplied for poweroff".to_string()), + task: Ok(Default::default()), + } + } + } + + impl WorkerPingResult { + pub fn poweroff(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.poweroff = value + .try_into() + .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerPingResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerPingResult, + ) -> ::std::result::Result { + Ok(Self { + poweroff: value.poweroff?, + task: value.task?, + }) + } + } + + impl ::std::convert::From for WorkerPingResult { + fn from(value: super::WorkerPingResult) -> Self { + Self { + poweroff: Ok(value.poweroff), + task: Ok(value.task), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingTask { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerPingTask { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + script: Err("no value supplied for script".to_string()), + } + } + } + + impl WorkerPingTask { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerPingTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerPingTask, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + output_rules: value.output_rules?, + script: value.script?, + }) + } + } + + impl ::std::convert::From for WorkerPingTask { + fn from(value: super::WorkerPingTask) -> Self { + Self { + id: Ok(value.id), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerTask { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + owner: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerTask { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + owner: Err("no value supplied for owner".to_string()), + } + } + } + + impl WorkerTask { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerTask, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + owner: value.owner?, + }) + } + } + + impl ::std::convert::From for WorkerTask { + fn from(value: super::WorkerTask) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + owner: Ok(value.owner), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkersResult { + workers: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for WorkersResult { + fn default() -> Self { + Self { + workers: Err("no value supplied for workers".to_string()), + } + } + } + + impl WorkersResult { + pub fn workers(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.workers = value + .try_into() + .map_err(|e| format!("error converting supplied value for workers: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkersResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkersResult, + ) -> ::std::result::Result { + Ok(Self { + workers: value.workers?, + }) + } + } + + impl ::std::convert::From for WorkersResult { + fn from(value: super::WorkersResult) -> Self { + Self { + workers: Ok(value.workers), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `POST` request to `/v1/control/hold` + /// + ///```ignore + /// let response = client.control_hold() + /// .send() + /// .await; + /// ``` + pub fn control_hold(&self) -> builder::ControlHold<'_> { + builder::ControlHold::new(self) + } + + ///Sends a `POST` request to `/v1/control/resume` + /// + ///```ignore + /// let response = client.control_resume() + /// .send() + /// .await; + /// ``` + pub fn control_resume(&self) -> builder::ControlResume<'_> { + builder::ControlResume::new(self) + } + + ///Sends a `GET` request to `/v1/task/{Task}` + /// + ///```ignore + /// let response = client.task_get() + /// .task(task) + /// .send() + /// .await; + /// ``` + pub fn task_get(&self) -> builder::TaskGet<'_> { + builder::TaskGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks` + /// + ///```ignore + /// let response = client.tasks_get() + /// .send() + /// .await; + /// ``` + pub fn tasks_get(&self) -> builder::TasksGet<'_> { + builder::TasksGet::new(self) + } + + ///Sends a `POST` request to `/v1/tasks` + /// + ///```ignore + /// let response = client.task_submit() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn task_submit(&self) -> builder::TaskSubmit<'_> { + builder::TaskSubmit::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/events` + /// + ///```ignore + /// let response = client.task_events_get() + /// .task(task) + /// .minseq(minseq) + /// .send() + /// .await; + /// ``` + pub fn task_events_get(&self) -> builder::TaskEventsGet<'_> { + builder::TaskEventsGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` + /// + ///```ignore + /// let response = client.task_outputs_get() + /// .task(task) + /// .send() + /// .await; + /// ``` + pub fn task_outputs_get(&self) -> builder::TaskOutputsGet<'_> { + builder::TaskOutputsGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` + /// + ///```ignore + /// let response = client.task_output_download() + /// .task(task) + /// .output(output) + /// .send() + /// .await; + /// ``` + pub fn task_output_download(&self) -> builder::TaskOutputDownload<'_> { + builder::TaskOutputDownload::new(self) + } + + ///Sends a `POST` request to `/v1/users` + /// + ///```ignore + /// let response = client.user_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn user_create(&self) -> builder::UserCreate<'_> { + builder::UserCreate::new(self) + } + + ///Sends a `GET` request to `/v1/whoami` + /// + ///```ignore + /// let response = client.whoami() + /// .send() + /// .await; + /// ``` + pub fn whoami(&self) -> builder::Whoami<'_> { + builder::Whoami::new(self) + } + + ///Sends a `PUT` request to `/v1/whoami/name` + /// + ///```ignore + /// let response = client.whoami_put_name() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn whoami_put_name(&self) -> builder::WhoamiPutName<'_> { + builder::WhoamiPutName::new(self) + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + /// + ///```ignore + /// let response = client.worker_bootstrap() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap<'_> { + builder::WorkerBootstrap::new(self) + } + + ///Sends a `GET` request to `/v1/worker/ping` + /// + ///```ignore + /// let response = client.worker_ping() + /// .send() + /// .await; + /// ``` + pub fn worker_ping(&self) -> builder::WorkerPing<'_> { + builder::WorkerPing::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/append` + /// + ///```ignore + /// let response = client.worker_task_append() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_append(&self) -> builder::WorkerTaskAppend<'_> { + builder::WorkerTaskAppend::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` + /// + ///```ignore + /// let response = client.worker_task_upload_chunk() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_upload_chunk(&self) -> builder::WorkerTaskUploadChunk<'_> { + builder::WorkerTaskUploadChunk::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + /// + ///```ignore + /// let response = client.worker_task_complete() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete<'_> { + builder::WorkerTaskComplete::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/output` + /// + ///```ignore + /// let response = client.worker_task_add_output() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_add_output(&self) -> builder::WorkerTaskAddOutput<'_> { + builder::WorkerTaskAddOutput::new(self) + } + + ///Sends a `GET` request to `/v1/workers` + /// + ///```ignore + /// let response = client.workers_list() + /// .send() + /// .await; + /// ``` + pub fn workers_list(&self) -> builder::WorkersList<'_> { + builder::WorkersList::new(self) + } + + ///Sends a `POST` request to `/v1/workers/recycle` + /// + ///```ignore + /// let response = client.workers_recycle() + /// .send() + /// .await; + /// ``` + pub fn workers_recycle(&self) -> builder::WorkersRecycle<'_> { + builder::WorkersRecycle::new(self) + } + + ///Sends a `GET` request to `/v1/things` + /// + ///```ignore + /// let response = client.get_thing_or_things() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn get_thing_or_things(&self) -> builder::GetThingOrThings<'_> { + builder::GetThingOrThings::new(self) + } + + ///Sends a `GET` request to `/v1/header-arg` + /// + ///```ignore + /// let response = client.header_arg() + /// .accept_language(accept_language) + /// .send() + /// .await; + /// ``` + pub fn header_arg(&self) -> builder::HeaderArg<'_> { + builder::HeaderArg::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Debug, Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/control/hold` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/control/hold", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_hold", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Debug, Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/control/resume` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/control/resume", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_resume", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_get`] + /// + ///[`Client::task_get`]: super::Client::task_get + #[derive(Debug, Clone)] + pub struct TaskGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + } + + impl<'a> TaskGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/task/{Task}` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task } = self; + let task = task.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/task/{}", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::tasks_get`] + /// + ///[`Client::tasks_get`]: super::Client::tasks_get + #[derive(Debug, Clone)] + pub struct TasksGet<'a> { + client: &'a super::Client, + } + + impl<'a> TasksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/tasks` + pub async fn send(self) -> Result>, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "tasks_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_submit`] + /// + ///[`Client::task_submit`]: super::Client::task_submit + #[derive(Debug, Clone)] + pub struct TaskSubmit<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> TaskSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `TaskSubmit` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/tasks` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "task_submit", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_events_get`] + /// + ///[`Client::task_events_get`]: super::Client::task_events_get + #[derive(Debug, Clone)] + pub struct TaskEventsGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + minseq: Result, String>, + } + + impl<'a> TaskEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + minseq: Ok(None), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn minseq(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.minseq = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/events` + pub async fn send( + self, + ) -> Result>, Error<()>> { + let Self { + client, + task, + minseq, + } = self; + let task = task.map_err(Error::InvalidRequest)?; + let minseq = minseq.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/events", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("minseq", &minseq)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_events_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_outputs_get`] + /// + ///[`Client::task_outputs_get`]: super::Client::task_outputs_get + #[derive(Debug, Clone)] + pub struct TaskOutputsGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + } + + impl<'a> TaskOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` + pub async fn send( + self, + ) -> Result>, Error<()>> { + let Self { client, task } = self; + let task = task.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/outputs", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_outputs_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_output_download`] + /// + ///[`Client::task_output_download`]: super::Client::task_output_download + #[derive(Debug, Clone)] + pub struct TaskOutputDownload<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + output: Result<::std::string::String, String>, + } + + impl<'a> TaskOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.output = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for output failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + task, + output, + } = self; + let task = task.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/outputs/{}", + client.baseurl, + encode_path(&task.to_string()), + encode_path(&output.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_output_download", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::user_create`] + /// + ///[`Client::user_create`]: super::Client::user_create + #[derive(Debug, Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/users` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/users", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "user_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami`] + /// + ///[`Client::whoami`]: super::Client::whoami + #[derive(Debug, Clone)] + pub struct Whoami<'a> { + client: &'a super::Client, + } + + impl<'a> Whoami<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/whoami` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/whoami", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "whoami", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami_put_name`] + /// + ///[`Client::whoami_put_name`]: super::Client::whoami_put_name + #[derive(Debug)] + pub struct WhoamiPutName<'a> { + client: &'a super::Client, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> WhoamiPutName<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `String` for body failed".to_string()) + .map(|v| v.into()); + self + } + + ///Sends a `PUT` request to `/v1/whoami/name` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/whoami/name", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "text/plain") + .body(body)?; + let info = OperationInfo { + operation_id: "whoami_put_name", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_bootstrap`] + /// + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + #[derive(Debug, Clone)] + pub struct WorkerBootstrap<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> WorkerBootstrap<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerBootstrap` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_bootstrap", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_ping`] + /// + ///[`Client::worker_ping`]: super::Client::worker_ping + #[derive(Debug, Clone)] + pub struct WorkerPing<'a> { + client: &'a super::Client, + } + + impl<'a> WorkerPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/worker/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/worker/ping", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "worker_ping", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_append`] + /// + ///[`Client::worker_task_append`]: super::Client::worker_task_append + #[derive(Debug, Clone)] + pub struct WorkerTaskAppend<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerAppendTask` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerAppendTask, + ) -> types::builder::WorkerAppendTask, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/append` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerAppendTask::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/append", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_append", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_upload_chunk`] + /// + ///[`Client::worker_task_upload_chunk`]: super::Client::worker_task_upload_chunk + #[derive(Debug)] + pub struct WorkerTaskUploadChunk<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> WorkerTaskUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto<::wasm_bindgen::JsValue>, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `wasm_bindgen::JsValue` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/chunk", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "worker_task_upload_chunk", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_complete`] + /// + ///[`Client::worker_task_complete`]: super::Client::worker_task_complete + #[derive(Debug, Clone)] + pub struct WorkerTaskComplete<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskComplete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerCompleteTask` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerCompleteTask::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/complete", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_complete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_add_output`] + /// + ///[`Client::worker_task_add_output`]: super::Client::worker_task_add_output + #[derive(Debug, Clone)] + pub struct WorkerTaskAddOutput<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskAddOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerAddOutput` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAddOutput) -> types::builder::WorkerAddOutput, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerAddOutput::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/output", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_add_output", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_list`] + /// + ///[`Client::workers_list`]: super::Client::workers_list + #[derive(Debug, Clone)] + pub struct WorkersList<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/workers` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/workers", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Debug, Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/workers/recycle` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/workers/recycle", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_recycle", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::get_thing_or_things`] + /// + ///[`Client::get_thing_or_things`]: super::Client::get_thing_or_things + #[derive(Debug, Clone)] + pub struct GetThingOrThings<'a> { + client: &'a super::Client, + id: Result, String>, + } + + impl<'a> GetThingOrThings<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Ok(None), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `GetThingOrThingsId` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/things` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/things", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "get_thing_or_things", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::header_arg`] + /// + ///[`Client::header_arg`]: super::Client::header_arg + #[derive(Debug, Clone)] + pub struct HeaderArg<'a> { + client: &'a super::Client, + accept_language: Result, String>, + } + + impl<'a> HeaderArg<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + accept_language: Ok(None), + } + } + + pub fn accept_language(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.accept_language = value.try_into().map(Some).map_err(|_| { + "conversion to `HeaderArgAcceptLanguage` for accept_language failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/header-arg` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + accept_language, + } = self; + let accept_language = accept_language.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/header-arg", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "header_arg", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::empty(response)), + _ => Err(Error::ErrorResponse(ResponseValue::empty(response))), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder_tagged.rs new file mode 100644 index 00000000..bc786745 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/buildomat_builder_tagged.rs @@ -0,0 +1,3881 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`GetThingOrThingsId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string" + /// }, + /// { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum GetThingOrThingsId { + String(::std::string::String), + Array(::std::vec::Vec<::std::string::String>), + } + + impl ::std::convert::From<&Self> for GetThingOrThingsId { + fn from(value: &GetThingOrThingsId) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for GetThingOrThingsId { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self::Array(value) + } + } + + ///`HeaderArgAcceptLanguage` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "default": "en", + /// "type": "string", + /// "enum": [ + /// "de", + /// "en" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum HeaderArgAcceptLanguage { + #[serde(rename = "de")] + De, + #[serde(rename = "en")] + En, + } + + impl ::std::convert::From<&Self> for HeaderArgAcceptLanguage { + fn from(value: &HeaderArgAcceptLanguage) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for HeaderArgAcceptLanguage { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::De => f.write_str("de"), + Self::En => f.write_str("en"), + } + } + } + + impl ::std::str::FromStr for HeaderArgAcceptLanguage { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "de" => Ok(Self::De), + "en" => Ok(Self::En), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::default::Default for HeaderArgAcceptLanguage { + fn default() -> Self { + HeaderArgAcceptLanguage::En + } + } + + ///`ObjWithOptionArray` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "stranger-things", + /// "things" + /// ], + /// "properties": { + /// "stranger-things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ], + /// "oneOf": [ + /// {} + /// ] + /// } + /// ] + /// } + /// }, + /// "things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ] + /// } + /// ] + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ObjWithOptionArray { + #[serde(rename = "stranger-things")] + pub stranger_things: ::std::vec::Vec<::std::option::Option>, + pub things: ::std::vec::Vec<::std::option::Option>, + } + + impl ::std::convert::From<&ObjWithOptionArray> for ObjWithOptionArray { + fn from(value: &ObjWithOptionArray) -> Self { + value.clone() + } + } + + impl ObjWithOptionArray { + pub fn builder() -> builder::ObjWithOptionArray { + Default::default() + } + } + + ///`Task` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "output_rules", + /// "script", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "state": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Task { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + pub state: ::std::string::String, + } + + impl ::std::convert::From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() + } + } + + impl Task { + pub fn builder() -> builder::Task { + Default::default() + } + } + + ///`TaskEvent` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "seq", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "seq": { + /// "type": "integer", + /// "format": "uint", + /// "minimum": 0.0 + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskEvent { + pub payload: ::std::string::String, + pub seq: u32, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&TaskEvent> for TaskEvent { + fn from(value: &TaskEvent) -> Self { + value.clone() + } + } + + impl TaskEvent { + pub fn builder() -> builder::TaskEvent { + Default::default() + } + } + + ///`TaskOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskOutput { + pub id: ::std::string::String, + pub path: ::std::string::String, + pub size: u64, + } + + impl ::std::convert::From<&TaskOutput> for TaskOutput { + fn from(value: &TaskOutput) -> Self { + value.clone() + } + } + + impl TaskOutput { + pub fn builder() -> builder::TaskOutput { + Default::default() + } + } + + ///`TaskSubmit` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "default", + /// "name", + /// "script" + /// ], + /// "properties": { + /// "default": { + /// "type": "boolean" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskSubmit { + pub default: bool, + pub name: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() + } + } + + impl TaskSubmit { + pub fn builder() -> builder::TaskSubmit { + Default::default() + } + } + + ///`TaskSubmitResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskSubmitResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmitResult> for TaskSubmitResult { + fn from(value: &TaskSubmitResult) -> Self { + value.clone() + } + } + + impl TaskSubmitResult { + pub fn builder() -> builder::TaskSubmitResult { + Default::default() + } + } + + ///`UploadedChunk` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UploadedChunk { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() + } + } + + impl UploadedChunk { + pub fn builder() -> builder::UploadedChunk { + Default::default() + } + } + + ///`UserCreate` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreate { + pub name: ::std::string::String, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + Default::default() + } + } + + ///`UserCreateResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "token" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreateResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + impl UserCreateResult { + pub fn builder() -> builder::UserCreateResult { + Default::default() + } + } + + ///`WhoamiResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WhoamiResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + impl WhoamiResult { + pub fn builder() -> builder::WhoamiResult { + Default::default() + } + } + + ///`Worker` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "deleted", + /// "id", + /// "recycle", + /// "tasks" + /// ], + /// "properties": { + /// "deleted": { + /// "type": "boolean" + /// }, + /// "id": { + /// "type": "string" + /// }, + /// "instance_id": { + /// "type": "string" + /// }, + /// "lastping": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "recycle": { + /// "type": "boolean" + /// }, + /// "tasks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/WorkerTask" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Worker { + pub deleted: bool, + pub id: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub instance_id: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub lastping: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + pub recycle: bool, + pub tasks: ::std::vec::Vec, + } + + impl ::std::convert::From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + impl Worker { + pub fn builder() -> builder::Worker { + Default::default() + } + } + + ///`WorkerAddOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "chunks", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "chunks": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerAddOutput { + pub chunks: ::std::vec::Vec<::std::string::String>, + pub path: ::std::string::String, + pub size: i64, + } + + impl ::std::convert::From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + impl WorkerAddOutput { + pub fn builder() -> builder::WorkerAddOutput { + Default::default() + } + } + + ///`WorkerAppendTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerAppendTask { + pub payload: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&WorkerAppendTask> for WorkerAppendTask { + fn from(value: &WorkerAppendTask) -> Self { + value.clone() + } + } + + impl WorkerAppendTask { + pub fn builder() -> builder::WorkerAppendTask { + Default::default() + } + } + + ///`WorkerBootstrap` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootstrap", + /// "token" + /// ], + /// "properties": { + /// "bootstrap": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerBootstrap { + pub bootstrap: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + impl WorkerBootstrap { + pub fn builder() -> builder::WorkerBootstrap { + Default::default() + } + } + + ///`WorkerBootstrapResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerBootstrapResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + impl WorkerBootstrapResult { + pub fn builder() -> builder::WorkerBootstrapResult { + Default::default() + } + } + + ///`WorkerCompleteTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "failed" + /// ], + /// "properties": { + /// "failed": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl ::std::convert::From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + impl WorkerCompleteTask { + pub fn builder() -> builder::WorkerCompleteTask { + Default::default() + } + } + + ///`WorkerPingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "poweroff" + /// ], + /// "properties": { + /// "poweroff": { + /// "type": "boolean" + /// }, + /// "task": { + /// "$ref": "#/components/schemas/WorkerPingTask" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerPingResult { + pub poweroff: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + } + + impl ::std::convert::From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + impl WorkerPingResult { + pub fn builder() -> builder::WorkerPingResult { + Default::default() + } + } + + ///`WorkerPingTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "output_rules", + /// "script" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerPingTask { + pub id: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + impl WorkerPingTask { + pub fn builder() -> builder::WorkerPingTask { + Default::default() + } + } + + ///`WorkerTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "owner" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "owner": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerTask { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub owner: ::std::string::String, + } + + impl ::std::convert::From<&WorkerTask> for WorkerTask { + fn from(value: &WorkerTask) -> Self { + value.clone() + } + } + + impl WorkerTask { + pub fn builder() -> builder::WorkerTask { + Default::default() + } + } + + ///`WorkersResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "workers" + /// ], + /// "properties": { + /// "workers": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Worker" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkersResult { + pub workers: ::std::vec::Vec, + } + + impl ::std::convert::From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } + + impl WorkersResult { + pub fn builder() -> builder::WorkersResult { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct ObjWithOptionArray { + stranger_things: ::std::result::Result< + ::std::vec::Vec<::std::option::Option>, + ::std::string::String, + >, + things: ::std::result::Result< + ::std::vec::Vec<::std::option::Option>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ObjWithOptionArray { + fn default() -> Self { + Self { + stranger_things: Err("no value supplied for stranger_things".to_string()), + things: Err("no value supplied for things".to_string()), + } + } + } + + impl ObjWithOptionArray { + pub fn stranger_things(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::option::Option>>, + T::Error: ::std::fmt::Display, + { + self.stranger_things = value.try_into().map_err(|e| { + format!("error converting supplied value for stranger_things: {}", e) + }); + self + } + pub fn things(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::option::Option>>, + T::Error: ::std::fmt::Display, + { + self.things = value + .try_into() + .map_err(|e| format!("error converting supplied value for things: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ObjWithOptionArray { + type Error = super::error::ConversionError; + fn try_from( + value: ObjWithOptionArray, + ) -> ::std::result::Result { + Ok(Self { + stranger_things: value.stranger_things?, + things: value.things?, + }) + } + } + + impl ::std::convert::From for ObjWithOptionArray { + fn from(value: super::ObjWithOptionArray) -> Self { + Self { + stranger_things: Ok(value.stranger_things), + things: Ok(value.things), + } + } + } + + #[derive(Clone, Debug)] + pub struct Task { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + state: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Task { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + script: Err("no value supplied for script".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Task { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Task { + type Error = super::error::ConversionError; + fn try_from(value: Task) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + output_rules: value.output_rules?, + script: value.script?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Task { + fn from(value: super::Task) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskEvent { + payload: ::std::result::Result<::std::string::String, ::std::string::String>, + seq: ::std::result::Result, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for TaskEvent { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + seq: Err("no value supplied for seq".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl TaskEvent { + pub fn payload(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn seq(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.seq = value + .try_into() + .map_err(|e| format!("error converting supplied value for seq: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskEvent { + type Error = super::error::ConversionError; + fn try_from( + value: TaskEvent, + ) -> ::std::result::Result { + Ok(Self { + payload: value.payload?, + seq: value.seq?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for TaskEvent { + fn from(value: super::TaskEvent) -> Self { + Self { + payload: Ok(value.payload), + seq: Ok(value.seq), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskOutput { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + path: ::std::result::Result<::std::string::String, ::std::string::String>, + size: ::std::result::Result, + } + + impl ::std::default::Default for TaskOutput { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl TaskOutput { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskOutput { + type Error = super::error::ConversionError; + fn try_from( + value: TaskOutput, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + path: value.path?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for TaskOutput { + fn from(value: super::TaskOutput) -> Self { + Self { + id: Ok(value.id), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmit { + default: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for TaskSubmit { + fn default() -> Self { + Self { + default: Err("no value supplied for default".to_string()), + name: Err("no value supplied for name".to_string()), + output_rules: Ok(Default::default()), + script: Err("no value supplied for script".to_string()), + } + } + } + + impl TaskSubmit { + pub fn default(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.default = value + .try_into() + .map_err(|e| format!("error converting supplied value for default: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskSubmit { + type Error = super::error::ConversionError; + fn try_from( + value: TaskSubmit, + ) -> ::std::result::Result { + Ok(Self { + default: value.default?, + name: value.name?, + output_rules: value.output_rules?, + script: value.script?, + }) + } + } + + impl ::std::convert::From for TaskSubmit { + fn from(value: super::TaskSubmit) -> Self { + Self { + default: Ok(value.default), + name: Ok(value.name), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + } + } + } + + #[derive(Clone, Debug)] + pub struct TaskSubmitResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for TaskSubmitResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl TaskSubmitResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TaskSubmitResult { + type Error = super::error::ConversionError; + fn try_from( + value: TaskSubmitResult, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for TaskSubmitResult { + fn from(value: super::TaskSubmitResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct UploadedChunk { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UploadedChunk { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl UploadedChunk { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UploadedChunk { + type Error = super::error::ConversionError; + fn try_from( + value: UploadedChunk, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for UploadedChunk { + fn from(value: super::UploadedChunk) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UserCreate { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl UserCreate { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreate { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreate, + ) -> ::std::result::Result { + Ok(Self { name: value.name? }) + } + } + + impl ::std::convert::From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreateResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + token: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for UserCreateResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl UserCreateResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreateResult { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreateResult, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + token: value.token?, + }) + } + } + + impl ::std::convert::From for UserCreateResult { + fn from(value: super::UserCreateResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WhoamiResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WhoamiResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl WhoamiResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WhoamiResult { + type Error = super::error::ConversionError; + fn try_from( + value: WhoamiResult, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for WhoamiResult { + fn from(value: super::WhoamiResult) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Worker { + deleted: ::std::result::Result, + id: ::std::result::Result<::std::string::String, ::std::string::String>, + instance_id: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + lastping: ::std::result::Result< + ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + ::std::string::String, + >, + recycle: ::std::result::Result, + tasks: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for Worker { + fn default() -> Self { + Self { + deleted: Err("no value supplied for deleted".to_string()), + id: Err("no value supplied for id".to_string()), + instance_id: Ok(Default::default()), + lastping: Ok(Default::default()), + recycle: Err("no value supplied for recycle".to_string()), + tasks: Err("no value supplied for tasks".to_string()), + } + } + } + + impl Worker { + pub fn deleted(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.deleted = value + .try_into() + .map_err(|e| format!("error converting supplied value for deleted: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn instance_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.instance_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); + self + } + pub fn lastping(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + >, + T::Error: ::std::fmt::Display, + { + self.lastping = value + .try_into() + .map_err(|e| format!("error converting supplied value for lastping: {}", e)); + self + } + pub fn recycle(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.recycle = value + .try_into() + .map_err(|e| format!("error converting supplied value for recycle: {}", e)); + self + } + pub fn tasks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.tasks = value + .try_into() + .map_err(|e| format!("error converting supplied value for tasks: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Worker { + type Error = super::error::ConversionError; + fn try_from( + value: Worker, + ) -> ::std::result::Result { + Ok(Self { + deleted: value.deleted?, + id: value.id?, + instance_id: value.instance_id?, + lastping: value.lastping?, + recycle: value.recycle?, + tasks: value.tasks?, + }) + } + } + + impl ::std::convert::From for Worker { + fn from(value: super::Worker) -> Self { + Self { + deleted: Ok(value.deleted), + id: Ok(value.id), + instance_id: Ok(value.instance_id), + lastping: Ok(value.lastping), + recycle: Ok(value.recycle), + tasks: Ok(value.tasks), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAddOutput { + chunks: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + path: ::std::result::Result<::std::string::String, ::std::string::String>, + size: ::std::result::Result, + } + + impl ::std::default::Default for WorkerAddOutput { + fn default() -> Self { + Self { + chunks: Err("no value supplied for chunks".to_string()), + path: Err("no value supplied for path".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl WorkerAddOutput { + pub fn chunks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.chunks = value + .try_into() + .map_err(|e| format!("error converting supplied value for chunks: {}", e)); + self + } + pub fn path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.path = value + .try_into() + .map_err(|e| format!("error converting supplied value for path: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerAddOutput { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerAddOutput, + ) -> ::std::result::Result { + Ok(Self { + chunks: value.chunks?, + path: value.path?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for WorkerAddOutput { + fn from(value: super::WorkerAddOutput) -> Self { + Self { + chunks: Ok(value.chunks), + path: Ok(value.path), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerAppendTask { + payload: ::std::result::Result<::std::string::String, ::std::string::String>, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for WorkerAppendTask { + fn default() -> Self { + Self { + payload: Err("no value supplied for payload".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl WorkerAppendTask { + pub fn payload(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.payload = value + .try_into() + .map_err(|e| format!("error converting supplied value for payload: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerAppendTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerAppendTask, + ) -> ::std::result::Result { + Ok(Self { + payload: value.payload?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for WorkerAppendTask { + fn from(value: super::WorkerAppendTask) -> Self { + Self { + payload: Ok(value.payload), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrap { + bootstrap: ::std::result::Result<::std::string::String, ::std::string::String>, + token: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerBootstrap { + fn default() -> Self { + Self { + bootstrap: Err("no value supplied for bootstrap".to_string()), + token: Err("no value supplied for token".to_string()), + } + } + } + + impl WorkerBootstrap { + pub fn bootstrap(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.bootstrap = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootstrap: {}", e)); + self + } + pub fn token(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.token = value + .try_into() + .map_err(|e| format!("error converting supplied value for token: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerBootstrap { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrap, + ) -> ::std::result::Result { + Ok(Self { + bootstrap: value.bootstrap?, + token: value.token?, + }) + } + } + + impl ::std::convert::From for WorkerBootstrap { + fn from(value: super::WorkerBootstrap) -> Self { + Self { + bootstrap: Ok(value.bootstrap), + token: Ok(value.token), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerBootstrapResult { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerBootstrapResult { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + } + } + } + + impl WorkerBootstrapResult { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerBootstrapResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrapResult, + ) -> ::std::result::Result { + Ok(Self { id: value.id? }) + } + } + + impl ::std::convert::From for WorkerBootstrapResult { + fn from(value: super::WorkerBootstrapResult) -> Self { + Self { id: Ok(value.id) } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerCompleteTask { + failed: ::std::result::Result, + } + + impl ::std::default::Default for WorkerCompleteTask { + fn default() -> Self { + Self { + failed: Err("no value supplied for failed".to_string()), + } + } + } + + impl WorkerCompleteTask { + pub fn failed(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.failed = value + .try_into() + .map_err(|e| format!("error converting supplied value for failed: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerCompleteTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerCompleteTask, + ) -> ::std::result::Result { + Ok(Self { + failed: value.failed?, + }) + } + } + + impl ::std::convert::From for WorkerCompleteTask { + fn from(value: super::WorkerCompleteTask) -> Self { + Self { + failed: Ok(value.failed), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingResult { + poweroff: ::std::result::Result, + task: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + } + + impl ::std::default::Default for WorkerPingResult { + fn default() -> Self { + Self { + poweroff: Err("no value supplied for poweroff".to_string()), + task: Ok(Default::default()), + } + } + } + + impl WorkerPingResult { + pub fn poweroff(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.poweroff = value + .try_into() + .map_err(|e| format!("error converting supplied value for poweroff: {}", e)); + self + } + pub fn task(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.task = value + .try_into() + .map_err(|e| format!("error converting supplied value for task: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerPingResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerPingResult, + ) -> ::std::result::Result { + Ok(Self { + poweroff: value.poweroff?, + task: value.task?, + }) + } + } + + impl ::std::convert::From for WorkerPingResult { + fn from(value: super::WorkerPingResult) -> Self { + Self { + poweroff: Ok(value.poweroff), + task: Ok(value.task), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerPingTask { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + output_rules: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerPingTask { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + output_rules: Err("no value supplied for output_rules".to_string()), + script: Err("no value supplied for script".to_string()), + } + } + } + + impl WorkerPingTask { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn output_rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.output_rules = value.try_into().map_err(|e| { + format!("error converting supplied value for output_rules: {}", e) + }); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerPingTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerPingTask, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + output_rules: value.output_rules?, + script: value.script?, + }) + } + } + + impl ::std::convert::From for WorkerPingTask { + fn from(value: super::WorkerPingTask) -> Self { + Self { + id: Ok(value.id), + output_rules: Ok(value.output_rules), + script: Ok(value.script), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkerTask { + id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + owner: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for WorkerTask { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + owner: Err("no value supplied for owner".to_string()), + } + } + } + + impl WorkerTask { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn owner(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.owner = value + .try_into() + .map_err(|e| format!("error converting supplied value for owner: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkerTask { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerTask, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + name: value.name?, + owner: value.owner?, + }) + } + } + + impl ::std::convert::From for WorkerTask { + fn from(value: super::WorkerTask) -> Self { + Self { + id: Ok(value.id), + name: Ok(value.name), + owner: Ok(value.owner), + } + } + } + + #[derive(Clone, Debug)] + pub struct WorkersResult { + workers: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for WorkersResult { + fn default() -> Self { + Self { + workers: Err("no value supplied for workers".to_string()), + } + } + } + + impl WorkersResult { + pub fn workers(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.workers = value + .try_into() + .map_err(|e| format!("error converting supplied value for workers: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::WorkersResult { + type Error = super::error::ConversionError; + fn try_from( + value: WorkersResult, + ) -> ::std::result::Result { + Ok(Self { + workers: value.workers?, + }) + } + } + + impl ::std::convert::From for WorkersResult { + fn from(value: super::WorkersResult) -> Self { + Self { + workers: Ok(value.workers), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `POST` request to `/v1/control/hold` + /// + ///```ignore + /// let response = client.control_hold() + /// .send() + /// .await; + /// ``` + pub fn control_hold(&self) -> builder::ControlHold<'_> { + builder::ControlHold::new(self) + } + + ///Sends a `POST` request to `/v1/control/resume` + /// + ///```ignore + /// let response = client.control_resume() + /// .send() + /// .await; + /// ``` + pub fn control_resume(&self) -> builder::ControlResume<'_> { + builder::ControlResume::new(self) + } + + ///Sends a `GET` request to `/v1/task/{Task}` + /// + ///```ignore + /// let response = client.task_get() + /// .task(task) + /// .send() + /// .await; + /// ``` + pub fn task_get(&self) -> builder::TaskGet<'_> { + builder::TaskGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks` + /// + ///```ignore + /// let response = client.tasks_get() + /// .send() + /// .await; + /// ``` + pub fn tasks_get(&self) -> builder::TasksGet<'_> { + builder::TasksGet::new(self) + } + + ///Sends a `POST` request to `/v1/tasks` + /// + ///```ignore + /// let response = client.task_submit() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn task_submit(&self) -> builder::TaskSubmit<'_> { + builder::TaskSubmit::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/events` + /// + ///```ignore + /// let response = client.task_events_get() + /// .task(task) + /// .minseq(minseq) + /// .send() + /// .await; + /// ``` + pub fn task_events_get(&self) -> builder::TaskEventsGet<'_> { + builder::TaskEventsGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` + /// + ///```ignore + /// let response = client.task_outputs_get() + /// .task(task) + /// .send() + /// .await; + /// ``` + pub fn task_outputs_get(&self) -> builder::TaskOutputsGet<'_> { + builder::TaskOutputsGet::new(self) + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` + /// + ///```ignore + /// let response = client.task_output_download() + /// .task(task) + /// .output(output) + /// .send() + /// .await; + /// ``` + pub fn task_output_download(&self) -> builder::TaskOutputDownload<'_> { + builder::TaskOutputDownload::new(self) + } + + ///Sends a `POST` request to `/v1/users` + /// + ///```ignore + /// let response = client.user_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn user_create(&self) -> builder::UserCreate<'_> { + builder::UserCreate::new(self) + } + + ///Sends a `GET` request to `/v1/whoami` + /// + ///```ignore + /// let response = client.whoami() + /// .send() + /// .await; + /// ``` + pub fn whoami(&self) -> builder::Whoami<'_> { + builder::Whoami::new(self) + } + + ///Sends a `PUT` request to `/v1/whoami/name` + /// + ///```ignore + /// let response = client.whoami_put_name() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn whoami_put_name(&self) -> builder::WhoamiPutName<'_> { + builder::WhoamiPutName::new(self) + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + /// + ///```ignore + /// let response = client.worker_bootstrap() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_bootstrap(&self) -> builder::WorkerBootstrap<'_> { + builder::WorkerBootstrap::new(self) + } + + ///Sends a `GET` request to `/v1/worker/ping` + /// + ///```ignore + /// let response = client.worker_ping() + /// .send() + /// .await; + /// ``` + pub fn worker_ping(&self) -> builder::WorkerPing<'_> { + builder::WorkerPing::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/append` + /// + ///```ignore + /// let response = client.worker_task_append() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_append(&self) -> builder::WorkerTaskAppend<'_> { + builder::WorkerTaskAppend::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` + /// + ///```ignore + /// let response = client.worker_task_upload_chunk() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_upload_chunk(&self) -> builder::WorkerTaskUploadChunk<'_> { + builder::WorkerTaskUploadChunk::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + /// + ///```ignore + /// let response = client.worker_task_complete() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_complete(&self) -> builder::WorkerTaskComplete<'_> { + builder::WorkerTaskComplete::new(self) + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/output` + /// + ///```ignore + /// let response = client.worker_task_add_output() + /// .task(task) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn worker_task_add_output(&self) -> builder::WorkerTaskAddOutput<'_> { + builder::WorkerTaskAddOutput::new(self) + } + + ///Sends a `GET` request to `/v1/workers` + /// + ///```ignore + /// let response = client.workers_list() + /// .send() + /// .await; + /// ``` + pub fn workers_list(&self) -> builder::WorkersList<'_> { + builder::WorkersList::new(self) + } + + ///Sends a `POST` request to `/v1/workers/recycle` + /// + ///```ignore + /// let response = client.workers_recycle() + /// .send() + /// .await; + /// ``` + pub fn workers_recycle(&self) -> builder::WorkersRecycle<'_> { + builder::WorkersRecycle::new(self) + } + + ///Sends a `GET` request to `/v1/things` + /// + ///```ignore + /// let response = client.get_thing_or_things() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn get_thing_or_things(&self) -> builder::GetThingOrThings<'_> { + builder::GetThingOrThings::new(self) + } + + ///Sends a `GET` request to `/v1/header-arg` + /// + ///```ignore + /// let response = client.header_arg() + /// .accept_language(accept_language) + /// .send() + /// .await; + /// ``` + pub fn header_arg(&self) -> builder::HeaderArg<'_> { + builder::HeaderArg::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Debug, Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/control/hold` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/control/hold", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_hold", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Debug, Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/control/resume` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/control/resume", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_resume", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_get`] + /// + ///[`Client::task_get`]: super::Client::task_get + #[derive(Debug, Clone)] + pub struct TaskGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + } + + impl<'a> TaskGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/task/{Task}` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task } = self; + let task = task.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/task/{}", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::tasks_get`] + /// + ///[`Client::tasks_get`]: super::Client::tasks_get + #[derive(Debug, Clone)] + pub struct TasksGet<'a> { + client: &'a super::Client, + } + + impl<'a> TasksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/tasks` + pub async fn send(self) -> Result>, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "tasks_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_submit`] + /// + ///[`Client::task_submit`]: super::Client::task_submit + #[derive(Debug, Clone)] + pub struct TaskSubmit<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> TaskSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `TaskSubmit` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/tasks` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "task_submit", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_events_get`] + /// + ///[`Client::task_events_get`]: super::Client::task_events_get + #[derive(Debug, Clone)] + pub struct TaskEventsGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + minseq: Result, String>, + } + + impl<'a> TaskEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + minseq: Ok(None), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn minseq(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.minseq = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u32` for minseq failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/events` + pub async fn send( + self, + ) -> Result>, Error<()>> { + let Self { + client, + task, + minseq, + } = self; + let task = task.map_err(Error::InvalidRequest)?; + let minseq = minseq.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/events", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("minseq", &minseq)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_events_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_outputs_get`] + /// + ///[`Client::task_outputs_get`]: super::Client::task_outputs_get + #[derive(Debug, Clone)] + pub struct TaskOutputsGet<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + } + + impl<'a> TaskOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` + pub async fn send( + self, + ) -> Result>, Error<()>> { + let Self { client, task } = self; + let task = task.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/outputs", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_outputs_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_output_download`] + /// + ///[`Client::task_output_download`]: super::Client::task_output_download + #[derive(Debug, Clone)] + pub struct TaskOutputDownload<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + output: Result<::std::string::String, String>, + } + + impl<'a> TaskOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + output: Err("output was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn output(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.output = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for output failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + task, + output, + } = self; + let task = task.map_err(Error::InvalidRequest)?; + let output = output.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/tasks/{}/outputs/{}", + client.baseurl, + encode_path(&task.to_string()), + encode_path(&output.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_output_download", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::user_create`] + /// + ///[`Client::user_create`]: super::Client::user_create + #[derive(Debug, Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/users` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/users", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "user_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami`] + /// + ///[`Client::whoami`]: super::Client::whoami + #[derive(Debug, Clone)] + pub struct Whoami<'a> { + client: &'a super::Client, + } + + impl<'a> Whoami<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/whoami` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/whoami", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "whoami", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami_put_name`] + /// + ///[`Client::whoami_put_name`]: super::Client::whoami_put_name + #[derive(Debug)] + pub struct WhoamiPutName<'a> { + client: &'a super::Client, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> WhoamiPutName<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `String` for body failed".to_string()) + .map(|v| v.into()); + self + } + + ///Sends a `PUT` request to `/v1/whoami/name` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/whoami/name", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "text/plain") + .body(body)?; + let info = OperationInfo { + operation_id: "whoami_put_name", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_bootstrap`] + /// + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + #[derive(Debug, Clone)] + pub struct WorkerBootstrap<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> WorkerBootstrap<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerBootstrap` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_bootstrap", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_ping`] + /// + ///[`Client::worker_ping`]: super::Client::worker_ping + #[derive(Debug, Clone)] + pub struct WorkerPing<'a> { + client: &'a super::Client, + } + + impl<'a> WorkerPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/worker/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/worker/ping", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "worker_ping", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_append`] + /// + ///[`Client::worker_task_append`]: super::Client::worker_task_append + #[derive(Debug, Clone)] + pub struct WorkerTaskAppend<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerAppendTask` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerAppendTask, + ) -> types::builder::WorkerAppendTask, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/append` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerAppendTask::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/append", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_append", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_upload_chunk`] + /// + ///[`Client::worker_task_upload_chunk`]: super::Client::worker_task_upload_chunk + #[derive(Debug)] + pub struct WorkerTaskUploadChunk<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> WorkerTaskUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto<::wasm_bindgen::JsValue>, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `wasm_bindgen::JsValue` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/chunk", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "worker_task_upload_chunk", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_complete`] + /// + ///[`Client::worker_task_complete`]: super::Client::worker_task_complete + #[derive(Debug, Clone)] + pub struct WorkerTaskComplete<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskComplete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerCompleteTask` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerCompleteTask::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/complete", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_complete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_task_add_output`] + /// + ///[`Client::worker_task_add_output`]: super::Client::worker_task_add_output + #[derive(Debug, Clone)] + pub struct WorkerTaskAddOutput<'a> { + client: &'a super::Client, + task: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> WorkerTaskAddOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + task: Err("task was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn task(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.task = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for task failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `WorkerAddOutput` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAddOutput) -> types::builder::WorkerAddOutput, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, task, body } = self; + let task = task.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::WorkerAddOutput::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/worker/task/{}/output", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_add_output", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_list`] + /// + ///[`Client::workers_list`]: super::Client::workers_list + #[derive(Debug, Clone)] + pub struct WorkersList<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/workers` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/workers", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Debug, Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/workers/recycle` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/v1/workers/recycle", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_recycle", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::get_thing_or_things`] + /// + ///[`Client::get_thing_or_things`]: super::Client::get_thing_or_things + #[derive(Debug, Clone)] + pub struct GetThingOrThings<'a> { + client: &'a super::Client, + id: Result, String>, + } + + impl<'a> GetThingOrThings<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Ok(None), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.id = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `GetThingOrThingsId` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/things` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/things", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "get_thing_or_things", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::header_arg`] + /// + ///[`Client::header_arg`]: super::Client::header_arg + #[derive(Debug, Clone)] + pub struct HeaderArg<'a> { + client: &'a super::Client, + accept_language: Result, String>, + } + + impl<'a> HeaderArg<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + accept_language: Ok(None), + } + } + + pub fn accept_language(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.accept_language = value.try_into().map(Some).map_err(|_| { + "conversion to `HeaderArgAcceptLanguage` for accept_language failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/v1/header-arg` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + accept_language, + } = self; + let accept_language = accept_language.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/header-arg", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "header_arg", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::empty(response)), + _ => Err(Error::ErrorResponse(ResponseValue::empty(response))), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/buildomat_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/buildomat_positional.rs new file mode 100644 index 00000000..cafbfca3 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/buildomat_positional.rs @@ -0,0 +1,1501 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`GetThingOrThingsId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string" + /// }, + /// { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum GetThingOrThingsId { + String(::std::string::String), + Array(::std::vec::Vec<::std::string::String>), + } + + impl ::std::convert::From<&Self> for GetThingOrThingsId { + fn from(value: &GetThingOrThingsId) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for GetThingOrThingsId { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self::Array(value) + } + } + + ///`HeaderArgAcceptLanguage` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "default": "en", + /// "type": "string", + /// "enum": [ + /// "de", + /// "en" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum HeaderArgAcceptLanguage { + #[serde(rename = "de")] + De, + #[serde(rename = "en")] + En, + } + + impl ::std::convert::From<&Self> for HeaderArgAcceptLanguage { + fn from(value: &HeaderArgAcceptLanguage) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for HeaderArgAcceptLanguage { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::De => f.write_str("de"), + Self::En => f.write_str("en"), + } + } + } + + impl ::std::str::FromStr for HeaderArgAcceptLanguage { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "de" => Ok(Self::De), + "en" => Ok(Self::En), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for HeaderArgAcceptLanguage { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::default::Default for HeaderArgAcceptLanguage { + fn default() -> Self { + HeaderArgAcceptLanguage::En + } + } + + ///`ObjWithOptionArray` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "stranger-things", + /// "things" + /// ], + /// "properties": { + /// "stranger-things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ], + /// "oneOf": [ + /// {} + /// ] + /// } + /// ] + /// } + /// }, + /// "things": { + /// "type": "array", + /// "items": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Task" + /// } + /// ] + /// } + /// ] + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ObjWithOptionArray { + #[serde(rename = "stranger-things")] + pub stranger_things: ::std::vec::Vec<::std::option::Option>, + pub things: ::std::vec::Vec<::std::option::Option>, + } + + impl ::std::convert::From<&ObjWithOptionArray> for ObjWithOptionArray { + fn from(value: &ObjWithOptionArray) -> Self { + value.clone() + } + } + + ///`Task` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "output_rules", + /// "script", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "state": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Task { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + pub state: ::std::string::String, + } + + impl ::std::convert::From<&Task> for Task { + fn from(value: &Task) -> Self { + value.clone() + } + } + + ///`TaskEvent` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "seq", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "seq": { + /// "type": "integer", + /// "format": "uint", + /// "minimum": 0.0 + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskEvent { + pub payload: ::std::string::String, + pub seq: u32, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&TaskEvent> for TaskEvent { + fn from(value: &TaskEvent) -> Self { + value.clone() + } + } + + ///`TaskOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskOutput { + pub id: ::std::string::String, + pub path: ::std::string::String, + pub size: u64, + } + + impl ::std::convert::From<&TaskOutput> for TaskOutput { + fn from(value: &TaskOutput) -> Self { + value.clone() + } + } + + ///`TaskSubmit` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "default", + /// "name", + /// "script" + /// ], + /// "properties": { + /// "default": { + /// "type": "boolean" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskSubmit { + pub default: bool, + pub name: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmit> for TaskSubmit { + fn from(value: &TaskSubmit) -> Self { + value.clone() + } + } + + ///`TaskSubmitResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TaskSubmitResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&TaskSubmitResult> for TaskSubmitResult { + fn from(value: &TaskSubmitResult) -> Self { + value.clone() + } + } + + ///`UploadedChunk` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UploadedChunk { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&UploadedChunk> for UploadedChunk { + fn from(value: &UploadedChunk) -> Self { + value.clone() + } + } + + ///`UserCreate` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreate { + pub name: ::std::string::String, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + ///`UserCreateResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "token" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreateResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&UserCreateResult> for UserCreateResult { + fn from(value: &UserCreateResult) -> Self { + value.clone() + } + } + + ///`WhoamiResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WhoamiResult { + pub id: ::std::string::String, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&WhoamiResult> for WhoamiResult { + fn from(value: &WhoamiResult) -> Self { + value.clone() + } + } + + ///`Worker` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "deleted", + /// "id", + /// "recycle", + /// "tasks" + /// ], + /// "properties": { + /// "deleted": { + /// "type": "boolean" + /// }, + /// "id": { + /// "type": "string" + /// }, + /// "instance_id": { + /// "type": "string" + /// }, + /// "lastping": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "recycle": { + /// "type": "boolean" + /// }, + /// "tasks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/WorkerTask" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Worker { + pub deleted: bool, + pub id: ::std::string::String, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub instance_id: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub lastping: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>, + pub recycle: bool, + pub tasks: ::std::vec::Vec, + } + + impl ::std::convert::From<&Worker> for Worker { + fn from(value: &Worker) -> Self { + value.clone() + } + } + + ///`WorkerAddOutput` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "chunks", + /// "path", + /// "size" + /// ], + /// "properties": { + /// "chunks": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "size": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerAddOutput { + pub chunks: ::std::vec::Vec<::std::string::String>, + pub path: ::std::string::String, + pub size: i64, + } + + impl ::std::convert::From<&WorkerAddOutput> for WorkerAddOutput { + fn from(value: &WorkerAddOutput) -> Self { + value.clone() + } + } + + ///`WorkerAppendTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "payload", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "payload": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerAppendTask { + pub payload: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&WorkerAppendTask> for WorkerAppendTask { + fn from(value: &WorkerAppendTask) -> Self { + value.clone() + } + } + + ///`WorkerBootstrap` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootstrap", + /// "token" + /// ], + /// "properties": { + /// "bootstrap": { + /// "type": "string" + /// }, + /// "token": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerBootstrap { + pub bootstrap: ::std::string::String, + pub token: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrap> for WorkerBootstrap { + fn from(value: &WorkerBootstrap) -> Self { + value.clone() + } + } + + ///`WorkerBootstrapResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerBootstrapResult { + pub id: ::std::string::String, + } + + impl ::std::convert::From<&WorkerBootstrapResult> for WorkerBootstrapResult { + fn from(value: &WorkerBootstrapResult) -> Self { + value.clone() + } + } + + ///`WorkerCompleteTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "failed" + /// ], + /// "properties": { + /// "failed": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + impl ::std::convert::From<&WorkerCompleteTask> for WorkerCompleteTask { + fn from(value: &WorkerCompleteTask) -> Self { + value.clone() + } + } + + ///`WorkerPingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "poweroff" + /// ], + /// "properties": { + /// "poweroff": { + /// "type": "boolean" + /// }, + /// "task": { + /// "$ref": "#/components/schemas/WorkerPingTask" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerPingResult { + pub poweroff: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub task: ::std::option::Option, + } + + impl ::std::convert::From<&WorkerPingResult> for WorkerPingResult { + fn from(value: &WorkerPingResult) -> Self { + value.clone() + } + } + + ///`WorkerPingTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "output_rules", + /// "script" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "output_rules": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// }, + /// "script": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerPingTask { + pub id: ::std::string::String, + pub output_rules: ::std::vec::Vec<::std::string::String>, + pub script: ::std::string::String, + } + + impl ::std::convert::From<&WorkerPingTask> for WorkerPingTask { + fn from(value: &WorkerPingTask) -> Self { + value.clone() + } + } + + ///`WorkerTask` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "name", + /// "owner" + /// ], + /// "properties": { + /// "id": { + /// "type": "string" + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "owner": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkerTask { + pub id: ::std::string::String, + pub name: ::std::string::String, + pub owner: ::std::string::String, + } + + impl ::std::convert::From<&WorkerTask> for WorkerTask { + fn from(value: &WorkerTask) -> Self { + value.clone() + } + } + + ///`WorkersResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "workers" + /// ], + /// "properties": { + /// "workers": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Worker" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct WorkersResult { + pub workers: ::std::vec::Vec, + } + + impl ::std::convert::From<&WorkersResult> for WorkersResult { + fn from(value: &WorkersResult) -> Self { + value.clone() + } + } +} + +#[derive(Clone, Debug)] +///Client for Buildomat +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Sends a `POST` request to `/v1/control/hold` + pub async fn control_hold<'a>(&'a self) -> Result, Error<()>> { + let url = format!("{}/v1/control/hold", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_hold", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/control/resume` + pub async fn control_resume<'a>(&'a self) -> Result, Error<()>> { + let url = format!("{}/v1/control/resume", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "control_resume", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/task/{Task}` + pub async fn task_get<'a>( + &'a self, + task: &'a str, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/task/{}", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/tasks` + pub async fn tasks_get<'a>( + &'a self, + ) -> Result>, Error<()>> { + let url = format!("{}/v1/tasks", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "tasks_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/tasks` + pub async fn task_submit<'a>( + &'a self, + body: &'a types::TaskSubmit, + ) -> Result, Error<()>> { + let url = format!("{}/v1/tasks", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "task_submit", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/tasks/{task}/events` + pub async fn task_events_get<'a>( + &'a self, + task: &'a str, + minseq: Option, + ) -> Result>, Error<()>> { + let url = format!( + "{}/v1/tasks/{}/events", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("minseq", &minseq)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_events_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` + pub async fn task_outputs_get<'a>( + &'a self, + task: &'a str, + ) -> Result>, Error<()>> { + let url = format!( + "{}/v1/tasks/{}/outputs", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_outputs_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` + pub async fn task_output_download<'a>( + &'a self, + task: &'a str, + output: &'a str, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/tasks/{}/outputs/{}", + self.baseurl, + encode_path(&task.to_string()), + encode_path(&output.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "task_output_download", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/users` + pub async fn user_create<'a>( + &'a self, + body: &'a types::UserCreate, + ) -> Result, Error<()>> { + let url = format!("{}/v1/users", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "user_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/whoami` + pub async fn whoami<'a>(&'a self) -> Result, Error<()>> { + let url = format!("{}/v1/whoami", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "whoami", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PUT` request to `/v1/whoami/name` + pub async fn whoami_put_name<'a>( + &'a self, + body: String, + ) -> Result, Error<()>> { + let url = format!("{}/v1/whoami/name", self.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("api-version", Self::api_version()) + .header("content-type", "text/plain") + .body(body)?; + let info = OperationInfo { + operation_id: "whoami_put_name", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + pub async fn worker_bootstrap<'a>( + &'a self, + body: &'a types::WorkerBootstrap, + ) -> Result, Error<()>> { + let url = format!("{}/v1/worker/bootstrap", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_bootstrap", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/worker/ping` + pub async fn worker_ping<'a>( + &'a self, + ) -> Result, Error<()>> { + let url = format!("{}/v1/worker/ping", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "worker_ping", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/append` + pub async fn worker_task_append<'a>( + &'a self, + task: &'a str, + body: &'a types::WorkerAppendTask, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/worker/task/{}/append", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_append", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` + pub async fn worker_task_upload_chunk<'a, B: Into<::wasm_bindgen::JsValue>>( + &'a self, + task: &'a str, + body: B, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/worker/task/{}/chunk", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "worker_task_upload_chunk", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` + pub async fn worker_task_complete<'a>( + &'a self, + task: &'a str, + body: &'a types::WorkerCompleteTask, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/worker/task/{}/complete", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_complete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/worker/task/{task}/output` + pub async fn worker_task_add_output<'a>( + &'a self, + task: &'a str, + body: &'a types::WorkerAddOutput, + ) -> Result, Error<()>> { + let url = format!( + "{}/v1/worker/task/{}/output", + self.baseurl, + encode_path(&task.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "worker_task_add_output", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/workers` + pub async fn workers_list<'a>( + &'a self, + ) -> Result, Error<()>> { + let url = format!("{}/v1/workers", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/v1/workers/recycle` + pub async fn workers_recycle<'a>(&'a self) -> Result, Error<()>> { + let url = format!("{}/v1/workers/recycle", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "workers_recycle", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/things` + pub async fn get_thing_or_things<'a>( + &'a self, + id: Option<&'a types::GetThingOrThingsId>, + ) -> Result, Error<()>> { + let url = format!("{}/v1/things", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "get_thing_or_things", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/v1/header-arg` + pub async fn header_arg<'a>( + &'a self, + accept_language: Option, + ) -> Result, Error<()>> { + let url = format!("{}/v1/header-arg", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "header_arg", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::empty(response)), + _ => Err(Error::ErrorResponse(ResponseValue::empty(response))), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder.rs new file mode 100644 index 00000000..6da623e4 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder.rs @@ -0,0 +1,293 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`UnoBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "required" + /// ], + /// "properties": { + /// "gateway": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UnoBody { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub gateway: ::std::option::Option<::std::string::String>, + pub required: ::serde_json::Value, + } + + impl ::std::convert::From<&UnoBody> for UnoBody { + fn from(value: &UnoBody) -> Self { + value.clone() + } + } + + impl UnoBody { + pub fn builder() -> builder::UnoBody { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct UnoBody { + gateway: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + required: ::std::result::Result<::serde_json::Value, ::std::string::String>, + } + + impl ::std::default::Default for UnoBody { + fn default() -> Self { + Self { + gateway: Ok(Default::default()), + required: Err("no value supplied for required".to_string()), + } + } + } + + impl UnoBody { + pub fn gateway(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.gateway = value + .try_into() + .map_err(|e| format!("error converting supplied value for gateway: {}", e)); + self + } + pub fn required(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::serde_json::Value>, + T::Error: ::std::fmt::Display, + { + self.required = value + .try_into() + .map_err(|e| format!("error converting supplied value for required: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UnoBody { + type Error = super::error::ConversionError; + fn try_from( + value: UnoBody, + ) -> ::std::result::Result { + Ok(Self { + gateway: value.gateway?, + required: value.required?, + }) + } + } + + impl ::std::convert::From for UnoBody { + fn from(value: super::UnoBody) -> Self { + Self { + gateway: Ok(value.gateway), + required: Ok(value.required), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for CLI gen test +/// +///Test case to exercise CLI generation +/// +///Version: 9000 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "9000" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `GET` request to `/uno` + /// + ///```ignore + /// let response = client.uno() + /// .gateway(gateway) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn uno(&self) -> builder::Uno<'_> { + builder::Uno::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::uno`] + /// + ///[`Client::uno`]: super::Client::uno + #[derive(Debug, Clone)] + pub struct Uno<'a> { + client: &'a super::Client, + gateway: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> Uno<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + gateway: Err("gateway was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn gateway(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.gateway = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for gateway failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UnoBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UnoBody) -> types::builder::UnoBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/uno` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + gateway, + body, + } = self; + let gateway = gateway.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::UnoBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/uno", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("gateway", &gateway)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "uno", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder_tagged.rs new file mode 100644 index 00000000..6674798e --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_builder_tagged.rs @@ -0,0 +1,293 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`UnoBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "required" + /// ], + /// "properties": { + /// "gateway": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UnoBody { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub gateway: ::std::option::Option<::std::string::String>, + pub required: ::serde_json::Value, + } + + impl ::std::convert::From<&UnoBody> for UnoBody { + fn from(value: &UnoBody) -> Self { + value.clone() + } + } + + impl UnoBody { + pub fn builder() -> builder::UnoBody { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct UnoBody { + gateway: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + required: ::std::result::Result<::serde_json::Value, ::std::string::String>, + } + + impl ::std::default::Default for UnoBody { + fn default() -> Self { + Self { + gateway: Ok(Default::default()), + required: Err("no value supplied for required".to_string()), + } + } + } + + impl UnoBody { + pub fn gateway(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.gateway = value + .try_into() + .map_err(|e| format!("error converting supplied value for gateway: {}", e)); + self + } + pub fn required(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::serde_json::Value>, + T::Error: ::std::fmt::Display, + { + self.required = value + .try_into() + .map_err(|e| format!("error converting supplied value for required: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UnoBody { + type Error = super::error::ConversionError; + fn try_from( + value: UnoBody, + ) -> ::std::result::Result { + Ok(Self { + gateway: value.gateway?, + required: value.required?, + }) + } + } + + impl ::std::convert::From for UnoBody { + fn from(value: super::UnoBody) -> Self { + Self { + gateway: Ok(value.gateway), + required: Ok(value.required), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for CLI gen test +/// +///Test case to exercise CLI generation +/// +///Version: 9000 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "9000" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `GET` request to `/uno` + /// + ///```ignore + /// let response = client.uno() + /// .gateway(gateway) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn uno(&self) -> builder::Uno<'_> { + builder::Uno::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::uno`] + /// + ///[`Client::uno`]: super::Client::uno + #[derive(Debug, Clone)] + pub struct Uno<'a> { + client: &'a super::Client, + gateway: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> Uno<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + gateway: Err("gateway was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn gateway(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.gateway = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for gateway failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UnoBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UnoBody) -> types::builder::UnoBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/uno` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + gateway, + body, + } = self; + let gateway = gateway.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::UnoBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/uno", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("gateway", &gateway)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "uno", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/cli_gen_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_positional.rs new file mode 100644 index 00000000..36277f6e --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/cli_gen_positional.rs @@ -0,0 +1,144 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`UnoBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "required" + /// ], + /// "properties": { + /// "gateway": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UnoBody { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub gateway: ::std::option::Option<::std::string::String>, + pub required: ::serde_json::Value, + } + + impl ::std::convert::From<&UnoBody> for UnoBody { + fn from(value: &UnoBody) -> Self { + value.clone() + } + } +} + +#[derive(Clone, Debug)] +///Client for CLI gen test +/// +///Test case to exercise CLI generation +/// +///Version: 9000 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "9000" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Sends a `GET` request to `/uno` + pub async fn uno<'a>( + &'a self, + gateway: &'a str, + body: &'a types::UnoBody, + ) -> Result, Error<()>> { + let url = format!("{}/uno", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("gateway", &gateway)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "uno", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/keeper_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/keeper_builder.rs new file mode 100644 index 00000000..e951e06b --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/keeper_builder.rs @@ -0,0 +1,1826 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`EnrolBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "EnrolBody", + /// "type": "object", + /// "required": [ + /// "host", + /// "key" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "key": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct EnrolBody { + pub host: ::std::string::String, + pub key: ::std::string::String, + } + + impl ::std::convert::From<&EnrolBody> for EnrolBody { + fn from(value: &EnrolBody) -> Self { + value.clone() + } + } + + impl EnrolBody { + pub fn builder() -> builder::EnrolBody { + Default::default() + } + } + + ///`GlobalJobsResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "GlobalJobsResult", + /// "type": "object", + /// "required": [ + /// "summary" + /// ], + /// "properties": { + /// "summary": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ReportSummary" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct GlobalJobsResult { + pub summary: ::std::vec::Vec, + } + + impl ::std::convert::From<&GlobalJobsResult> for GlobalJobsResult { + fn from(value: &GlobalJobsResult) -> Self { + value.clone() + } + } + + impl GlobalJobsResult { + pub fn builder() -> builder::GlobalJobsResult { + Default::default() + } + } + + ///`OutputRecord` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "msg", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "msg": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OutputRecord { + pub msg: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&OutputRecord> for OutputRecord { + fn from(value: &OutputRecord) -> Self { + value.clone() + } + } + + impl OutputRecord { + pub fn builder() -> builder::OutputRecord { + Default::default() + } + } + + ///`PingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "PingResult", + /// "type": "object", + /// "required": [ + /// "host", + /// "ok" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "ok": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct PingResult { + pub host: ::std::string::String, + pub ok: bool, + } + + impl ::std::convert::From<&PingResult> for PingResult { + fn from(value: &PingResult) -> Self { + value.clone() + } + } + + impl PingResult { + pub fn builder() -> builder::PingResult { + Default::default() + } + } + + ///`ReportFinishBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportFinishBody", + /// "type": "object", + /// "required": [ + /// "duration_millis", + /// "end_time", + /// "exit_status", + /// "id" + /// ], + /// "properties": { + /// "duration_millis": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "end_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "exit_status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportFinishBody { + pub duration_millis: usize, + pub end_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub exit_status: usize, + pub id: ReportId, + } + + impl ::std::convert::From<&ReportFinishBody> for ReportFinishBody { + fn from(value: &ReportFinishBody) -> Self { + value.clone() + } + } + + impl ReportFinishBody { + pub fn builder() -> builder::ReportFinishBody { + Default::default() + } + } + + ///`ReportId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "host", + /// "job", + /// "pid", + /// "time", + /// "uuid" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "pid": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "uuid": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportId { + pub host: ::std::string::String, + pub job: ::std::string::String, + pub pid: u64, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + pub uuid: ::std::string::String, + } + + impl ::std::convert::From<&ReportId> for ReportId { + fn from(value: &ReportId) -> Self { + value.clone() + } + } + + impl ReportId { + pub fn builder() -> builder::ReportId { + Default::default() + } + } + + ///`ReportOutputBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportOutputBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "record" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "record": { + /// "$ref": "#/components/schemas/OutputRecord" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportOutputBody { + pub id: ReportId, + pub record: OutputRecord, + } + + impl ::std::convert::From<&ReportOutputBody> for ReportOutputBody { + fn from(value: &ReportOutputBody) -> Self { + value.clone() + } + } + + impl ReportOutputBody { + pub fn builder() -> builder::ReportOutputBody { + Default::default() + } + } + + ///`ReportResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportResult", + /// "type": "object", + /// "required": [ + /// "existed_already" + /// ], + /// "properties": { + /// "existed_already": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportResult { + pub existed_already: bool, + } + + impl ::std::convert::From<&ReportResult> for ReportResult { + fn from(value: &ReportResult) -> Self { + value.clone() + } + } + + impl ReportResult { + pub fn builder() -> builder::ReportResult { + Default::default() + } + } + + ///`ReportStartBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportStartBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "script", + /// "start_time" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportStartBody { + pub id: ReportId, + pub script: ::std::string::String, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportStartBody> for ReportStartBody { + fn from(value: &ReportStartBody) -> Self { + value.clone() + } + } + + impl ReportStartBody { + pub fn builder() -> builder::ReportStartBody { + Default::default() + } + } + + ///`ReportSummary` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "age_seconds", + /// "duration_seconds", + /// "host", + /// "job", + /// "status", + /// "when" + /// ], + /// "properties": { + /// "age_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "duration_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "when": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ReportSummary { + pub age_seconds: usize, + pub duration_seconds: usize, + pub host: ::std::string::String, + pub job: ::std::string::String, + pub status: usize, + pub when: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportSummary> for ReportSummary { + fn from(value: &ReportSummary) -> Self { + value.clone() + } + } + + impl ReportSummary { + pub fn builder() -> builder::ReportSummary { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct EnrolBody { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + key: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for EnrolBody { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + key: Err("no value supplied for key".to_string()), + } + } + } + + impl EnrolBody { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::EnrolBody { + type Error = super::error::ConversionError; + fn try_from( + value: EnrolBody, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + key: value.key?, + }) + } + } + + impl ::std::convert::From for EnrolBody { + fn from(value: super::EnrolBody) -> Self { + Self { + host: Ok(value.host), + key: Ok(value.key), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalJobsResult { + summary: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for GlobalJobsResult { + fn default() -> Self { + Self { + summary: Err("no value supplied for summary".to_string()), + } + } + } + + impl GlobalJobsResult { + pub fn summary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.summary = value + .try_into() + .map_err(|e| format!("error converting supplied value for summary: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalJobsResult { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalJobsResult, + ) -> ::std::result::Result { + Ok(Self { + summary: value.summary?, + }) + } + } + + impl ::std::convert::From for GlobalJobsResult { + fn from(value: super::GlobalJobsResult) -> Self { + Self { + summary: Ok(value.summary), + } + } + } + + #[derive(Clone, Debug)] + pub struct OutputRecord { + msg: ::std::result::Result<::std::string::String, ::std::string::String>, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for OutputRecord { + fn default() -> Self { + Self { + msg: Err("no value supplied for msg".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl OutputRecord { + pub fn msg(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.msg = value + .try_into() + .map_err(|e| format!("error converting supplied value for msg: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OutputRecord { + type Error = super::error::ConversionError; + fn try_from( + value: OutputRecord, + ) -> ::std::result::Result { + Ok(Self { + msg: value.msg?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for OutputRecord { + fn from(value: super::OutputRecord) -> Self { + Self { + msg: Ok(value.msg), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct PingResult { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + ok: ::std::result::Result, + } + + impl ::std::default::Default for PingResult { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + ok: Err("no value supplied for ok".to_string()), + } + } + } + + impl PingResult { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn ok(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ok = value + .try_into() + .map_err(|e| format!("error converting supplied value for ok: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PingResult { + type Error = super::error::ConversionError; + fn try_from( + value: PingResult, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + ok: value.ok?, + }) + } + } + + impl ::std::convert::From for PingResult { + fn from(value: super::PingResult) -> Self { + Self { + host: Ok(value.host), + ok: Ok(value.ok), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportFinishBody { + duration_millis: ::std::result::Result, + end_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + exit_status: ::std::result::Result, + id: ::std::result::Result, + } + + impl ::std::default::Default for ReportFinishBody { + fn default() -> Self { + Self { + duration_millis: Err("no value supplied for duration_millis".to_string()), + end_time: Err("no value supplied for end_time".to_string()), + exit_status: Err("no value supplied for exit_status".to_string()), + id: Err("no value supplied for id".to_string()), + } + } + } + + impl ReportFinishBody { + pub fn duration_millis(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.duration_millis = value.try_into().map_err(|e| { + format!("error converting supplied value for duration_millis: {}", e) + }); + self + } + pub fn end_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.end_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for end_time: {}", e)); + self + } + pub fn exit_status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.exit_status = value + .try_into() + .map_err(|e| format!("error converting supplied value for exit_status: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportFinishBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportFinishBody, + ) -> ::std::result::Result { + Ok(Self { + duration_millis: value.duration_millis?, + end_time: value.end_time?, + exit_status: value.exit_status?, + id: value.id?, + }) + } + } + + impl ::std::convert::From for ReportFinishBody { + fn from(value: super::ReportFinishBody) -> Self { + Self { + duration_millis: Ok(value.duration_millis), + end_time: Ok(value.end_time), + exit_status: Ok(value.exit_status), + id: Ok(value.id), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportId { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + job: ::std::result::Result<::std::string::String, ::std::string::String>, + pid: ::std::result::Result, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + uuid: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for ReportId { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + job: Err("no value supplied for job".to_string()), + pid: Err("no value supplied for pid".to_string()), + time: Err("no value supplied for time".to_string()), + uuid: Err("no value supplied for uuid".to_string()), + } + } + } + + impl ReportId { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn job(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn pid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.pid = value + .try_into() + .map_err(|e| format!("error converting supplied value for pid: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + pub fn uuid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.uuid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uuid: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportId { + type Error = super::error::ConversionError; + fn try_from( + value: ReportId, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + job: value.job?, + pid: value.pid?, + time: value.time?, + uuid: value.uuid?, + }) + } + } + + impl ::std::convert::From for ReportId { + fn from(value: super::ReportId) -> Self { + Self { + host: Ok(value.host), + job: Ok(value.job), + pid: Ok(value.pid), + time: Ok(value.time), + uuid: Ok(value.uuid), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportOutputBody { + id: ::std::result::Result, + record: ::std::result::Result, + } + + impl ::std::default::Default for ReportOutputBody { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + record: Err("no value supplied for record".to_string()), + } + } + } + + impl ReportOutputBody { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn record(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.record = value + .try_into() + .map_err(|e| format!("error converting supplied value for record: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportOutputBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportOutputBody, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + record: value.record?, + }) + } + } + + impl ::std::convert::From for ReportOutputBody { + fn from(value: super::ReportOutputBody) -> Self { + Self { + id: Ok(value.id), + record: Ok(value.record), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportResult { + existed_already: ::std::result::Result, + } + + impl ::std::default::Default for ReportResult { + fn default() -> Self { + Self { + existed_already: Err("no value supplied for existed_already".to_string()), + } + } + } + + impl ReportResult { + pub fn existed_already(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.existed_already = value.try_into().map_err(|e| { + format!("error converting supplied value for existed_already: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::ReportResult { + type Error = super::error::ConversionError; + fn try_from( + value: ReportResult, + ) -> ::std::result::Result { + Ok(Self { + existed_already: value.existed_already?, + }) + } + } + + impl ::std::convert::From for ReportResult { + fn from(value: super::ReportResult) -> Self { + Self { + existed_already: Ok(value.existed_already), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportStartBody { + id: ::std::result::Result, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ReportStartBody { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + script: Err("no value supplied for script".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl ReportStartBody { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportStartBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportStartBody, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + script: value.script?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for ReportStartBody { + fn from(value: super::ReportStartBody) -> Self { + Self { + id: Ok(value.id), + script: Ok(value.script), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportSummary { + age_seconds: ::std::result::Result, + duration_seconds: ::std::result::Result, + host: ::std::result::Result<::std::string::String, ::std::string::String>, + job: ::std::result::Result<::std::string::String, ::std::string::String>, + status: ::std::result::Result, + when: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ReportSummary { + fn default() -> Self { + Self { + age_seconds: Err("no value supplied for age_seconds".to_string()), + duration_seconds: Err("no value supplied for duration_seconds".to_string()), + host: Err("no value supplied for host".to_string()), + job: Err("no value supplied for job".to_string()), + status: Err("no value supplied for status".to_string()), + when: Err("no value supplied for when".to_string()), + } + } + } + + impl ReportSummary { + pub fn age_seconds(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.age_seconds = value + .try_into() + .map_err(|e| format!("error converting supplied value for age_seconds: {}", e)); + self + } + pub fn duration_seconds(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.duration_seconds = value.try_into().map_err(|e| { + format!( + "error converting supplied value for duration_seconds: {}", + e + ) + }); + self + } + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn job(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn when(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.when = value + .try_into() + .map_err(|e| format!("error converting supplied value for when: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportSummary { + type Error = super::error::ConversionError; + fn try_from( + value: ReportSummary, + ) -> ::std::result::Result { + Ok(Self { + age_seconds: value.age_seconds?, + duration_seconds: value.duration_seconds?, + host: value.host?, + job: value.job?, + status: value.status?, + when: value.when?, + }) + } + } + + impl ::std::convert::From for ReportSummary { + fn from(value: super::ReportSummary) -> Self { + Self { + age_seconds: Ok(value.age_seconds), + duration_seconds: Ok(value.duration_seconds), + host: Ok(value.host), + job: Ok(value.job), + status: Ok(value.status), + when: Ok(value.when), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `POST` request to `/enrol` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.enrol() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn enrol(&self) -> builder::Enrol<'_> { + builder::Enrol::new(self) + } + + ///Sends a `GET` request to `/global/jobs` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + ///```ignore + /// let response = client.global_jobs() + /// .authorization(authorization) + /// .send() + /// .await; + /// ``` + pub fn global_jobs(&self) -> builder::GlobalJobs<'_> { + builder::GlobalJobs::new(self) + } + + ///Sends a `GET` request to `/ping` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + ///```ignore + /// let response = client.ping() + /// .authorization(authorization) + /// .send() + /// .await; + /// ``` + pub fn ping(&self) -> builder::Ping<'_> { + builder::Ping::new(self) + } + + ///Sends a `POST` request to `/report/finish` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_finish() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_finish(&self) -> builder::ReportFinish<'_> { + builder::ReportFinish::new(self) + } + + ///Sends a `POST` request to `/report/output` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_output() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_output(&self) -> builder::ReportOutput<'_> { + builder::ReportOutput::new(self) + } + + ///Sends a `POST` request to `/report/start` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_start() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_start(&self) -> builder::ReportStart<'_> { + builder::ReportStart::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::enrol`] + /// + ///[`Client::enrol`]: super::Client::enrol + #[derive(Debug, Clone)] + pub struct Enrol<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> Enrol<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `EnrolBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::EnrolBody) -> types::builder::EnrolBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/enrol` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::EnrolBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/enrol", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "enrol", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::global_jobs`] + /// + ///[`Client::global_jobs`]: super::Client::global_jobs + #[derive(Debug, Clone)] + pub struct GlobalJobs<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + } + + impl<'a> GlobalJobs<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/global/jobs` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let url = format!("{}/global/jobs", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "global_jobs", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ping`] + /// + ///[`Client::ping`]: super::Client::ping + #[derive(Debug, Clone)] + pub struct Ping<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + } + + impl<'a> Ping<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let url = format!("{}/ping", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ping", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_finish`] + /// + ///[`Client::report_finish`]: super::Client::report_finish + #[derive(Debug, Clone)] + pub struct ReportFinish<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportFinish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportFinishBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportFinishBody, + ) -> types::builder::ReportFinishBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/finish` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportFinishBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/finish", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_finish", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_output`] + /// + ///[`Client::report_output`]: super::Client::report_output + #[derive(Debug, Clone)] + pub struct ReportOutput<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportOutputBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportOutputBody, + ) -> types::builder::ReportOutputBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportOutputBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/output", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_output", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_start`] + /// + ///[`Client::report_start`]: super::Client::report_start + #[derive(Debug, Clone)] + pub struct ReportStart<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportStartBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ReportStartBody) -> types::builder::ReportStartBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/start` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportStartBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/start", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/keeper_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/keeper_builder_tagged.rs new file mode 100644 index 00000000..912980c7 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/keeper_builder_tagged.rs @@ -0,0 +1,1808 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`EnrolBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "EnrolBody", + /// "type": "object", + /// "required": [ + /// "host", + /// "key" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "key": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct EnrolBody { + pub host: ::std::string::String, + pub key: ::std::string::String, + } + + impl ::std::convert::From<&EnrolBody> for EnrolBody { + fn from(value: &EnrolBody) -> Self { + value.clone() + } + } + + impl EnrolBody { + pub fn builder() -> builder::EnrolBody { + Default::default() + } + } + + ///`GlobalJobsResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "GlobalJobsResult", + /// "type": "object", + /// "required": [ + /// "summary" + /// ], + /// "properties": { + /// "summary": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ReportSummary" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalJobsResult { + pub summary: ::std::vec::Vec, + } + + impl ::std::convert::From<&GlobalJobsResult> for GlobalJobsResult { + fn from(value: &GlobalJobsResult) -> Self { + value.clone() + } + } + + impl GlobalJobsResult { + pub fn builder() -> builder::GlobalJobsResult { + Default::default() + } + } + + ///`OutputRecord` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "msg", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "msg": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OutputRecord { + pub msg: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&OutputRecord> for OutputRecord { + fn from(value: &OutputRecord) -> Self { + value.clone() + } + } + + impl OutputRecord { + pub fn builder() -> builder::OutputRecord { + Default::default() + } + } + + ///`PingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "PingResult", + /// "type": "object", + /// "required": [ + /// "host", + /// "ok" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "ok": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PingResult { + pub host: ::std::string::String, + pub ok: bool, + } + + impl ::std::convert::From<&PingResult> for PingResult { + fn from(value: &PingResult) -> Self { + value.clone() + } + } + + impl PingResult { + pub fn builder() -> builder::PingResult { + Default::default() + } + } + + ///`ReportFinishBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportFinishBody", + /// "type": "object", + /// "required": [ + /// "duration_millis", + /// "end_time", + /// "exit_status", + /// "id" + /// ], + /// "properties": { + /// "duration_millis": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "end_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "exit_status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportFinishBody { + pub duration_millis: i32, + pub end_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub exit_status: i32, + pub id: ReportId, + } + + impl ::std::convert::From<&ReportFinishBody> for ReportFinishBody { + fn from(value: &ReportFinishBody) -> Self { + value.clone() + } + } + + impl ReportFinishBody { + pub fn builder() -> builder::ReportFinishBody { + Default::default() + } + } + + ///`ReportId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "host", + /// "job", + /// "pid", + /// "time", + /// "uuid" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "pid": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "uuid": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportId { + pub host: ::std::string::String, + pub job: ::std::string::String, + pub pid: u64, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + pub uuid: ::std::string::String, + } + + impl ::std::convert::From<&ReportId> for ReportId { + fn from(value: &ReportId) -> Self { + value.clone() + } + } + + impl ReportId { + pub fn builder() -> builder::ReportId { + Default::default() + } + } + + ///`ReportOutputBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportOutputBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "record" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "record": { + /// "$ref": "#/components/schemas/OutputRecord" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportOutputBody { + pub id: ReportId, + pub record: OutputRecord, + } + + impl ::std::convert::From<&ReportOutputBody> for ReportOutputBody { + fn from(value: &ReportOutputBody) -> Self { + value.clone() + } + } + + impl ReportOutputBody { + pub fn builder() -> builder::ReportOutputBody { + Default::default() + } + } + + ///`ReportResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportResult", + /// "type": "object", + /// "required": [ + /// "existed_already" + /// ], + /// "properties": { + /// "existed_already": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportResult { + pub existed_already: bool, + } + + impl ::std::convert::From<&ReportResult> for ReportResult { + fn from(value: &ReportResult) -> Self { + value.clone() + } + } + + impl ReportResult { + pub fn builder() -> builder::ReportResult { + Default::default() + } + } + + ///`ReportStartBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportStartBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "script", + /// "start_time" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportStartBody { + pub id: ReportId, + pub script: ::std::string::String, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportStartBody> for ReportStartBody { + fn from(value: &ReportStartBody) -> Self { + value.clone() + } + } + + impl ReportStartBody { + pub fn builder() -> builder::ReportStartBody { + Default::default() + } + } + + ///`ReportSummary` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "age_seconds", + /// "duration_seconds", + /// "host", + /// "job", + /// "status", + /// "when" + /// ], + /// "properties": { + /// "age_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "duration_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "when": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportSummary { + pub age_seconds: i32, + pub duration_seconds: i32, + pub host: ::std::string::String, + pub job: ::std::string::String, + pub status: i32, + pub when: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportSummary> for ReportSummary { + fn from(value: &ReportSummary) -> Self { + value.clone() + } + } + + impl ReportSummary { + pub fn builder() -> builder::ReportSummary { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct EnrolBody { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + key: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for EnrolBody { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + key: Err("no value supplied for key".to_string()), + } + } + } + + impl EnrolBody { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::EnrolBody { + type Error = super::error::ConversionError; + fn try_from( + value: EnrolBody, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + key: value.key?, + }) + } + } + + impl ::std::convert::From for EnrolBody { + fn from(value: super::EnrolBody) -> Self { + Self { + host: Ok(value.host), + key: Ok(value.key), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalJobsResult { + summary: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + } + + impl ::std::default::Default for GlobalJobsResult { + fn default() -> Self { + Self { + summary: Err("no value supplied for summary".to_string()), + } + } + } + + impl GlobalJobsResult { + pub fn summary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.summary = value + .try_into() + .map_err(|e| format!("error converting supplied value for summary: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalJobsResult { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalJobsResult, + ) -> ::std::result::Result { + Ok(Self { + summary: value.summary?, + }) + } + } + + impl ::std::convert::From for GlobalJobsResult { + fn from(value: super::GlobalJobsResult) -> Self { + Self { + summary: Ok(value.summary), + } + } + } + + #[derive(Clone, Debug)] + pub struct OutputRecord { + msg: ::std::result::Result<::std::string::String, ::std::string::String>, + stream: ::std::result::Result<::std::string::String, ::std::string::String>, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for OutputRecord { + fn default() -> Self { + Self { + msg: Err("no value supplied for msg".to_string()), + stream: Err("no value supplied for stream".to_string()), + time: Err("no value supplied for time".to_string()), + } + } + } + + impl OutputRecord { + pub fn msg(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.msg = value + .try_into() + .map_err(|e| format!("error converting supplied value for msg: {}", e)); + self + } + pub fn stream(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.stream = value + .try_into() + .map_err(|e| format!("error converting supplied value for stream: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OutputRecord { + type Error = super::error::ConversionError; + fn try_from( + value: OutputRecord, + ) -> ::std::result::Result { + Ok(Self { + msg: value.msg?, + stream: value.stream?, + time: value.time?, + }) + } + } + + impl ::std::convert::From for OutputRecord { + fn from(value: super::OutputRecord) -> Self { + Self { + msg: Ok(value.msg), + stream: Ok(value.stream), + time: Ok(value.time), + } + } + } + + #[derive(Clone, Debug)] + pub struct PingResult { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + ok: ::std::result::Result, + } + + impl ::std::default::Default for PingResult { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + ok: Err("no value supplied for ok".to_string()), + } + } + } + + impl PingResult { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn ok(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ok = value + .try_into() + .map_err(|e| format!("error converting supplied value for ok: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PingResult { + type Error = super::error::ConversionError; + fn try_from( + value: PingResult, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + ok: value.ok?, + }) + } + } + + impl ::std::convert::From for PingResult { + fn from(value: super::PingResult) -> Self { + Self { + host: Ok(value.host), + ok: Ok(value.ok), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportFinishBody { + duration_millis: ::std::result::Result, + end_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + exit_status: ::std::result::Result, + id: ::std::result::Result, + } + + impl ::std::default::Default for ReportFinishBody { + fn default() -> Self { + Self { + duration_millis: Err("no value supplied for duration_millis".to_string()), + end_time: Err("no value supplied for end_time".to_string()), + exit_status: Err("no value supplied for exit_status".to_string()), + id: Err("no value supplied for id".to_string()), + } + } + } + + impl ReportFinishBody { + pub fn duration_millis(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.duration_millis = value.try_into().map_err(|e| { + format!("error converting supplied value for duration_millis: {}", e) + }); + self + } + pub fn end_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.end_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for end_time: {}", e)); + self + } + pub fn exit_status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.exit_status = value + .try_into() + .map_err(|e| format!("error converting supplied value for exit_status: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportFinishBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportFinishBody, + ) -> ::std::result::Result { + Ok(Self { + duration_millis: value.duration_millis?, + end_time: value.end_time?, + exit_status: value.exit_status?, + id: value.id?, + }) + } + } + + impl ::std::convert::From for ReportFinishBody { + fn from(value: super::ReportFinishBody) -> Self { + Self { + duration_millis: Ok(value.duration_millis), + end_time: Ok(value.end_time), + exit_status: Ok(value.exit_status), + id: Ok(value.id), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportId { + host: ::std::result::Result<::std::string::String, ::std::string::String>, + job: ::std::result::Result<::std::string::String, ::std::string::String>, + pid: ::std::result::Result, + time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + uuid: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for ReportId { + fn default() -> Self { + Self { + host: Err("no value supplied for host".to_string()), + job: Err("no value supplied for job".to_string()), + pid: Err("no value supplied for pid".to_string()), + time: Err("no value supplied for time".to_string()), + uuid: Err("no value supplied for uuid".to_string()), + } + } + } + + impl ReportId { + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn job(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn pid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.pid = value + .try_into() + .map_err(|e| format!("error converting supplied value for pid: {}", e)); + self + } + pub fn time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time = value + .try_into() + .map_err(|e| format!("error converting supplied value for time: {}", e)); + self + } + pub fn uuid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.uuid = value + .try_into() + .map_err(|e| format!("error converting supplied value for uuid: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportId { + type Error = super::error::ConversionError; + fn try_from( + value: ReportId, + ) -> ::std::result::Result { + Ok(Self { + host: value.host?, + job: value.job?, + pid: value.pid?, + time: value.time?, + uuid: value.uuid?, + }) + } + } + + impl ::std::convert::From for ReportId { + fn from(value: super::ReportId) -> Self { + Self { + host: Ok(value.host), + job: Ok(value.job), + pid: Ok(value.pid), + time: Ok(value.time), + uuid: Ok(value.uuid), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportOutputBody { + id: ::std::result::Result, + record: ::std::result::Result, + } + + impl ::std::default::Default for ReportOutputBody { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + record: Err("no value supplied for record".to_string()), + } + } + } + + impl ReportOutputBody { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn record(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.record = value + .try_into() + .map_err(|e| format!("error converting supplied value for record: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportOutputBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportOutputBody, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + record: value.record?, + }) + } + } + + impl ::std::convert::From for ReportOutputBody { + fn from(value: super::ReportOutputBody) -> Self { + Self { + id: Ok(value.id), + record: Ok(value.record), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportResult { + existed_already: ::std::result::Result, + } + + impl ::std::default::Default for ReportResult { + fn default() -> Self { + Self { + existed_already: Err("no value supplied for existed_already".to_string()), + } + } + } + + impl ReportResult { + pub fn existed_already(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.existed_already = value.try_into().map_err(|e| { + format!("error converting supplied value for existed_already: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::ReportResult { + type Error = super::error::ConversionError; + fn try_from( + value: ReportResult, + ) -> ::std::result::Result { + Ok(Self { + existed_already: value.existed_already?, + }) + } + } + + impl ::std::convert::From for ReportResult { + fn from(value: super::ReportResult) -> Self { + Self { + existed_already: Ok(value.existed_already), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportStartBody { + id: ::std::result::Result, + script: ::std::result::Result<::std::string::String, ::std::string::String>, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ReportStartBody { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + script: Err("no value supplied for script".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl ReportStartBody { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn script(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.script = value + .try_into() + .map_err(|e| format!("error converting supplied value for script: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportStartBody { + type Error = super::error::ConversionError; + fn try_from( + value: ReportStartBody, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + script: value.script?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for ReportStartBody { + fn from(value: super::ReportStartBody) -> Self { + Self { + id: Ok(value.id), + script: Ok(value.script), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct ReportSummary { + age_seconds: ::std::result::Result, + duration_seconds: ::std::result::Result, + host: ::std::result::Result<::std::string::String, ::std::string::String>, + job: ::std::result::Result<::std::string::String, ::std::string::String>, + status: ::std::result::Result, + when: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ReportSummary { + fn default() -> Self { + Self { + age_seconds: Err("no value supplied for age_seconds".to_string()), + duration_seconds: Err("no value supplied for duration_seconds".to_string()), + host: Err("no value supplied for host".to_string()), + job: Err("no value supplied for job".to_string()), + status: Err("no value supplied for status".to_string()), + when: Err("no value supplied for when".to_string()), + } + } + } + + impl ReportSummary { + pub fn age_seconds(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.age_seconds = value + .try_into() + .map_err(|e| format!("error converting supplied value for age_seconds: {}", e)); + self + } + pub fn duration_seconds(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.duration_seconds = value.try_into().map_err(|e| { + format!( + "error converting supplied value for duration_seconds: {}", + e + ) + }); + self + } + pub fn host(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.host = value + .try_into() + .map_err(|e| format!("error converting supplied value for host: {}", e)); + self + } + pub fn job(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.job = value + .try_into() + .map_err(|e| format!("error converting supplied value for job: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn when(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.when = value + .try_into() + .map_err(|e| format!("error converting supplied value for when: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ReportSummary { + type Error = super::error::ConversionError; + fn try_from( + value: ReportSummary, + ) -> ::std::result::Result { + Ok(Self { + age_seconds: value.age_seconds?, + duration_seconds: value.duration_seconds?, + host: value.host?, + job: value.job?, + status: value.status?, + when: value.when?, + }) + } + } + + impl ::std::convert::From for ReportSummary { + fn from(value: super::ReportSummary) -> Self { + Self { + age_seconds: Ok(value.age_seconds), + duration_seconds: Ok(value.duration_seconds), + host: Ok(value.host), + job: Ok(value.job), + status: Ok(value.status), + when: Ok(value.when), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `POST` request to `/enrol` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.enrol() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn enrol(&self) -> builder::Enrol<'_> { + builder::Enrol::new(self) + } + + ///Sends a `GET` request to `/global/jobs` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + ///```ignore + /// let response = client.global_jobs() + /// .authorization(authorization) + /// .send() + /// .await; + /// ``` + pub fn global_jobs(&self) -> builder::GlobalJobs<'_> { + builder::GlobalJobs::new(self) + } + + ///Sends a `GET` request to `/ping` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + ///```ignore + /// let response = client.ping() + /// .authorization(authorization) + /// .send() + /// .await; + /// ``` + pub fn ping(&self) -> builder::Ping<'_> { + builder::Ping::new(self) + } + + ///Sends a `POST` request to `/report/finish` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_finish() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_finish(&self) -> builder::ReportFinish<'_> { + builder::ReportFinish::new(self) + } + + ///Sends a `POST` request to `/report/output` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_output() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_output(&self) -> builder::ReportOutput<'_> { + builder::ReportOutput::new(self) + } + + ///Sends a `POST` request to `/report/start` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + ///```ignore + /// let response = client.report_start() + /// .authorization(authorization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_start(&self) -> builder::ReportStart<'_> { + builder::ReportStart::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::enrol`] + /// + ///[`Client::enrol`]: super::Client::enrol + #[derive(Debug, Clone)] + pub struct Enrol<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> Enrol<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `EnrolBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::EnrolBody) -> types::builder::EnrolBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/enrol` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::EnrolBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/enrol", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "enrol", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::global_jobs`] + /// + ///[`Client::global_jobs`]: super::Client::global_jobs + #[derive(Debug, Clone)] + pub struct GlobalJobs<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + } + + impl<'a> GlobalJobs<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/global/jobs` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let url = format!("{}/global/jobs", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "global_jobs", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ping`] + /// + ///[`Client::ping`]: super::Client::ping + #[derive(Debug, Clone)] + pub struct Ping<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + } + + impl<'a> Ping<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let url = format!("{}/ping", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ping", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_finish`] + /// + ///[`Client::report_finish`]: super::Client::report_finish + #[derive(Debug, Clone)] + pub struct ReportFinish<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportFinish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportFinishBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportFinishBody, + ) -> types::builder::ReportFinishBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/finish` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportFinishBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/finish", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_finish", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_output`] + /// + ///[`Client::report_output`]: super::Client::report_output + #[derive(Debug, Clone)] + pub struct ReportOutput<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportOutputBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportOutputBody, + ) -> types::builder::ReportOutputBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportOutputBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/output", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_output", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_start`] + /// + ///[`Client::report_start`]: super::Client::report_start + #[derive(Debug, Clone)] + pub struct ReportStart<'a> { + client: &'a super::Client, + authorization: Result<::std::string::String, String>, + body: Result, + } + + impl<'a> ReportStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + authorization: Err("authorization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn authorization(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.authorization = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for authorization failed".to_string() + }); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ReportStartBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ReportStartBody) -> types::builder::ReportStartBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/report/start` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + authorization, + body, + } = self; + let authorization = authorization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ReportStartBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/report/start", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/keeper_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/keeper_positional.rs new file mode 100644 index 00000000..28e754cb --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/keeper_positional.rs @@ -0,0 +1,646 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`EnrolBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "EnrolBody", + /// "type": "object", + /// "required": [ + /// "host", + /// "key" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "key": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct EnrolBody { + pub host: ::std::string::String, + pub key: ::std::string::String, + } + + impl ::std::convert::From<&EnrolBody> for EnrolBody { + fn from(value: &EnrolBody) -> Self { + value.clone() + } + } + + ///`GlobalJobsResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "GlobalJobsResult", + /// "type": "object", + /// "required": [ + /// "summary" + /// ], + /// "properties": { + /// "summary": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ReportSummary" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalJobsResult { + pub summary: ::std::vec::Vec, + } + + impl ::std::convert::From<&GlobalJobsResult> for GlobalJobsResult { + fn from(value: &GlobalJobsResult) -> Self { + value.clone() + } + } + + ///`OutputRecord` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "msg", + /// "stream", + /// "time" + /// ], + /// "properties": { + /// "msg": { + /// "type": "string" + /// }, + /// "stream": { + /// "type": "string" + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OutputRecord { + pub msg: ::std::string::String, + pub stream: ::std::string::String, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&OutputRecord> for OutputRecord { + fn from(value: &OutputRecord) -> Self { + value.clone() + } + } + + ///`PingResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "PingResult", + /// "type": "object", + /// "required": [ + /// "host", + /// "ok" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "ok": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PingResult { + pub host: ::std::string::String, + pub ok: bool, + } + + impl ::std::convert::From<&PingResult> for PingResult { + fn from(value: &PingResult) -> Self { + value.clone() + } + } + + ///`ReportFinishBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportFinishBody", + /// "type": "object", + /// "required": [ + /// "duration_millis", + /// "end_time", + /// "exit_status", + /// "id" + /// ], + /// "properties": { + /// "duration_millis": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "end_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "exit_status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportFinishBody { + pub duration_millis: i32, + pub end_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub exit_status: i32, + pub id: ReportId, + } + + impl ::std::convert::From<&ReportFinishBody> for ReportFinishBody { + fn from(value: &ReportFinishBody) -> Self { + value.clone() + } + } + + ///`ReportId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "host", + /// "job", + /// "pid", + /// "time", + /// "uuid" + /// ], + /// "properties": { + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "pid": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "uuid": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportId { + pub host: ::std::string::String, + pub job: ::std::string::String, + pub pid: u64, + pub time: ::chrono::DateTime<::chrono::offset::Utc>, + pub uuid: ::std::string::String, + } + + impl ::std::convert::From<&ReportId> for ReportId { + fn from(value: &ReportId) -> Self { + value.clone() + } + } + + ///`ReportOutputBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportOutputBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "record" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "record": { + /// "$ref": "#/components/schemas/OutputRecord" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportOutputBody { + pub id: ReportId, + pub record: OutputRecord, + } + + impl ::std::convert::From<&ReportOutputBody> for ReportOutputBody { + fn from(value: &ReportOutputBody) -> Self { + value.clone() + } + } + + ///`ReportResult` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportResult", + /// "type": "object", + /// "required": [ + /// "existed_already" + /// ], + /// "properties": { + /// "existed_already": { + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportResult { + pub existed_already: bool, + } + + impl ::std::convert::From<&ReportResult> for ReportResult { + fn from(value: &ReportResult) -> Self { + value.clone() + } + } + + ///`ReportStartBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "ReportStartBody", + /// "type": "object", + /// "required": [ + /// "id", + /// "script", + /// "start_time" + /// ], + /// "properties": { + /// "id": { + /// "$ref": "#/components/schemas/ReportId" + /// }, + /// "script": { + /// "type": "string" + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportStartBody { + pub id: ReportId, + pub script: ::std::string::String, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportStartBody> for ReportStartBody { + fn from(value: &ReportStartBody) -> Self { + value.clone() + } + } + + ///`ReportSummary` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "age_seconds", + /// "duration_seconds", + /// "host", + /// "job", + /// "status", + /// "when" + /// ], + /// "properties": { + /// "age_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "duration_seconds": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "host": { + /// "type": "string" + /// }, + /// "job": { + /// "type": "string" + /// }, + /// "status": { + /// "type": "integer", + /// "format": "int32" + /// }, + /// "when": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ReportSummary { + pub age_seconds: i32, + pub duration_seconds: i32, + pub host: ::std::string::String, + pub job: ::std::string::String, + pub status: i32, + pub when: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&ReportSummary> for ReportSummary { + fn from(value: &ReportSummary) -> Self { + value.clone() + } + } +} + +#[derive(Clone, Debug)] +///Client for Keeper API +/// +///report execution of cron jobs through a mechanism other than mail +/// +///Version: 1.0 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "1.0" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Sends a `POST` request to `/enrol` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + pub async fn enrol<'a>( + &'a self, + authorization: &'a str, + body: &'a types::EnrolBody, + ) -> Result, Error<()>> { + let url = format!("{}/enrol", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "enrol", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/global/jobs` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + pub async fn global_jobs<'a>( + &'a self, + authorization: &'a str, + ) -> Result, Error<()>> { + let url = format!("{}/global/jobs", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "global_jobs", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/ping` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + pub async fn ping<'a>( + &'a self, + authorization: &'a str, + ) -> Result, Error<()>> { + let url = format!("{}/ping", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ping", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/report/finish` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + pub async fn report_finish<'a>( + &'a self, + authorization: &'a str, + body: &'a types::ReportFinishBody, + ) -> Result, Error<()>> { + let url = format!("{}/report/finish", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_finish", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/report/output` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + pub async fn report_output<'a>( + &'a self, + authorization: &'a str, + body: &'a types::ReportOutputBody, + ) -> Result, Error<()>> { + let url = format!("{}/report/output", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_output", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/report/start` + /// + ///Arguments: + /// - `authorization`: Authorization header (bearer token) + /// - `body` + pub async fn report_start<'a>( + &'a self, + authorization: &'a str, + body: &'a types::ReportStartBody, + ) -> Result, Error<()>> { + let url = format!("{}/report/start", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "report_start", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/nexus_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/nexus_builder.rs new file mode 100644 index 00000000..14b33ac5 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/nexus_builder.rs @@ -0,0 +1,50602 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///Describes properties that should uniquely identify a Gimlet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes properties that should uniquely identify a + /// Gimlet.", + /// "type": "object", + /// "required": [ + /// "part", + /// "revision", + /// "serial" + /// ], + /// "properties": { + /// "part": { + /// "type": "string" + /// }, + /// "revision": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "serial": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Baseboard { + pub part: ::std::string::String, + pub revision: i64, + pub serial: ::std::string::String, + } + + impl ::std::convert::From<&Baseboard> for Baseboard { + fn from(value: &Baseboard) -> Self { + value.clone() + } + } + + impl Baseboard { + pub fn builder() -> builder::Baseboard { + Default::default() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum BinRangedouble { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: f64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: f64, start: f64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: f64 }, + } + + impl ::std::convert::From<&Self> for BinRangedouble { + fn from(value: &BinRangedouble) -> Self { + value.clone() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum BinRangeint64 { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: i64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: i64, start: i64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: i64 }, + } + + impl ::std::convert::From<&Self> for BinRangeint64 { + fn from(value: &BinRangeint64) -> Self { + value.clone() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangedouble" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Bindouble { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangedouble, + } + + impl ::std::convert::From<&Bindouble> for Bindouble { + fn from(value: &Bindouble) -> Self { + value.clone() + } + } + + impl Bindouble { + pub fn builder() -> builder::Bindouble { + Default::default() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangeint64" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Binint64 { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangeint64, + } + + impl ::std::convert::From<&Binint64> for Binint64 { + fn from(value: &Binint64) -> Self { + value.clone() + } + } + + impl Binint64 { + pub fn builder() -> builder::Binint64 { + Default::default() + } + } + + ///`BlockSize` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "disk block size in bytes", + /// "type": "integer", + /// "enum": [ + /// 512, + /// 2048, + /// 4096 + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, schemars :: JsonSchema)] + #[serde(transparent)] + pub struct BlockSize(i64); + impl ::std::ops::Deref for BlockSize { + type Target = i64; + fn deref(&self) -> &i64 { + &self.0 + } + } + + impl ::std::convert::From for i64 { + fn from(value: BlockSize) -> Self { + value.0 + } + } + + impl ::std::convert::From<&BlockSize> for BlockSize { + fn from(value: &BlockSize) -> Self { + value.clone() + } + } + + impl ::std::convert::TryFrom for BlockSize { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> ::std::result::Result { + if ![512_i64, 2048_i64, 4096_i64].contains(&value) { + Err("invalid value".into()) + } else { + Ok(Self(value)) + } + } + } + + impl<'de> ::serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + Self::try_from(::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + + ///A count of bytes, typically used either for memory or storage capacity + /// + ///The maximum supported byte count is [`i64::MAX`]. This makes it + /// somewhat inconvenient to define constructors: a u32 constructor can be + /// infallible, but an i64 constructor can fail (if the value is negative) + /// and a u64 constructor can fail (if the value is larger than i64::MAX). + /// We provide all of these for consumers' convenience. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A count of bytes, typically used either for memory or + /// storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. + /// This makes it somewhat inconvenient to define constructors: a u32 + /// constructor can be infallible, but an i64 constructor can fail (if the + /// value is negative) and a u64 constructor can fail (if the value is + /// larger than i64::MAX). We provide all of these for consumers' + /// convenience.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct ByteCount(pub u64); + impl ::std::ops::Deref for ByteCount { + type Target = u64; + fn deref(&self) -> &u64 { + &self.0 + } + } + + impl ::std::convert::From for u64 { + fn from(value: ByteCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&ByteCount> for ByteCount { + fn from(value: &ByteCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for ByteCount { + fn from(value: u64) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for ByteCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for ByteCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for ByteCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for ByteCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for ByteCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of a [`Certificate`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Certificate`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "service", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "service": { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Certificate> for Certificate { + fn from(value: &Certificate) -> Self { + value.clone() + } + } + + impl Certificate { + pub fn builder() -> builder::Certificate { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate)", + /// "type": "object", + /// "required": [ + /// "cert", + /// "description", + /// "key", + /// "name", + /// "service" + /// ], + /// "properties": { + /// "cert": { + /// "description": "PEM file containing public certificate chain", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "key": { + /// "description": "PEM file containing private key", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "service": { + /// "description": "The service using this certificate", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: ::std::vec::Vec, + pub description: ::std::string::String, + ///PEM file containing private key + pub key: ::std::vec::Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + impl ::std::convert::From<&CertificateCreate> for CertificateCreate { + fn from(value: &CertificateCreate) -> Self { + value.clone() + } + } + + impl CertificateCreate { + pub fn builder() -> builder::CertificateCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Certificate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&CertificateResultsPage> for CertificateResultsPage { + fn from(value: &CertificateResultsPage) -> Self { + value.clone() + } + } + + impl CertificateResultsPage { + pub fn builder() -> builder::CertificateResultsPage { + Default::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&ComponentUpdate> for ComponentUpdate { + fn from(value: &ComponentUpdate) -> Self { + value.clone() + } + } + + impl ComponentUpdate { + pub fn builder() -> builder::ComponentUpdate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ComponentUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ComponentUpdateResultsPage> for ComponentUpdateResultsPage { + fn from(value: &ComponentUpdateResultsPage) -> Self { + value.clone() + } + } + + impl ComponentUpdateResultsPage { + pub fn builder() -> builder::ComponentUpdateResultsPage { + Default::default() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "number", + /// "format": "double" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Cumulativedouble { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: f64, + } + + impl ::std::convert::From<&Cumulativedouble> for Cumulativedouble { + fn from(value: &Cumulativedouble) -> Self { + value.clone() + } + } + + impl Cumulativedouble { + pub fn builder() -> builder::Cumulativedouble { + Default::default() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Cumulativeint64 { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: i64, + } + + impl ::std::convert::From<&Cumulativeint64> for Cumulativeint64 { + fn from(value: &Cumulativeint64) -> Self { + value.clone() + } + } + + impl Cumulativeint64 { + pub fn builder() -> builder::Cumulativeint64 { + Default::default() + } + } + + ///A `Datum` is a single sampled data point from a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Datum` is a single sampled data point from a + /// metric.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "boolean" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bool" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "string" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bytes" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativeint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativedouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramdouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_f64" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "datum")] + pub enum Datum { + #[serde(rename = "bool")] + Bool(bool), + #[serde(rename = "i64")] + I64(i64), + #[serde(rename = "f64")] + F64(f64), + #[serde(rename = "string")] + String(::std::string::String), + #[serde(rename = "bytes")] + Bytes(::std::vec::Vec), + #[serde(rename = "cumulative_i64")] + CumulativeI64(Cumulativeint64), + #[serde(rename = "cumulative_f64")] + CumulativeF64(Cumulativedouble), + #[serde(rename = "histogram_i64")] + HistogramI64(Histogramint64), + #[serde(rename = "histogram_f64")] + HistogramF64(Histogramdouble), + } + + impl ::std::convert::From<&Self> for Datum { + fn from(value: &Datum) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Datum { + fn from(value: bool) -> Self { + Self::Bool(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: i64) -> Self { + Self::I64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: f64) -> Self { + Self::F64(value) + } + } + + impl ::std::convert::From<::std::vec::Vec> for Datum { + fn from(value: ::std::vec::Vec) -> Self { + Self::Bytes(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativeint64) -> Self { + Self::CumulativeI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativedouble) -> Self { + Self::CumulativeF64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramint64) -> Self { + Self::HistogramI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramdouble) -> Self { + Self::HistogramF64(value) + } + } + + ///The type of an individual datum of a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The type of an individual datum of a metric.", + /// "type": "string", + /// "enum": [ + /// "bool", + /// "i64", + /// "f64", + /// "string", + /// "bytes", + /// "cumulative_i64", + /// "cumulative_f64", + /// "histogram_i64", + /// "histogram_f64" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum DatumType { + #[serde(rename = "bool")] + Bool, + #[serde(rename = "i64")] + I64, + #[serde(rename = "f64")] + F64, + #[serde(rename = "string")] + String, + #[serde(rename = "bytes")] + Bytes, + #[serde(rename = "cumulative_i64")] + CumulativeI64, + #[serde(rename = "cumulative_f64")] + CumulativeF64, + #[serde(rename = "histogram_i64")] + HistogramI64, + #[serde(rename = "histogram_f64")] + HistogramF64, + } + + impl ::std::convert::From<&Self> for DatumType { + fn from(value: &DatumType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DatumType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Bool => f.write_str("bool"), + Self::I64 => f.write_str("i64"), + Self::F64 => f.write_str("f64"), + Self::String => f.write_str("string"), + Self::Bytes => f.write_str("bytes"), + Self::CumulativeI64 => f.write_str("cumulative_i64"), + Self::CumulativeF64 => f.write_str("cumulative_f64"), + Self::HistogramI64 => f.write_str("histogram_i64"), + Self::HistogramF64 => f.write_str("histogram_f64"), + } + } + } + + impl ::std::str::FromStr for DatumType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bool" => Ok(Self::Bool), + "i64" => Ok(Self::I64), + "f64" => Ok(Self::F64), + "string" => Ok(Self::String), + "bytes" => Ok(Self::Bytes), + "cumulative_i64" => Ok(Self::CumulativeI64), + "cumulative_f64" => Ok(Self::CumulativeF64), + "histogram_i64" => Ok(Self::HistogramI64), + "histogram_f64" => Ok(Self::HistogramF64), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DatumType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DerEncodedKeyPair` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "private_key", + /// "public_cert" + /// ], + /// "properties": { + /// "private_key": { + /// "description": "request signing private key (base64 encoded der + /// file)", + /// "type": "string" + /// }, + /// "public_cert": { + /// "description": "request signing public certificate (base64 encoded + /// der file)", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DerEncodedKeyPair { + ///request signing private key (base64 encoded der file) + pub private_key: ::std::string::String, + ///request signing public certificate (base64 encoded der file) + pub public_cert: ::std::string::String, + } + + impl ::std::convert::From<&DerEncodedKeyPair> for DerEncodedKeyPair { + fn from(value: &DerEncodedKeyPair) -> Self { + value.clone() + } + } + + impl DerEncodedKeyPair { + pub fn builder() -> builder::DerEncodedKeyPair { + Default::default() + } + } + + ///`DeviceAccessTokenRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id", + /// "device_code", + /// "grant_type" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "device_code": { + /// "type": "string" + /// }, + /// "grant_type": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DeviceAccessTokenRequest { + pub client_id: ::uuid::Uuid, + pub device_code: ::std::string::String, + pub grant_type: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAccessTokenRequest> for DeviceAccessTokenRequest { + fn from(value: &DeviceAccessTokenRequest) -> Self { + value.clone() + } + } + + impl DeviceAccessTokenRequest { + pub fn builder() -> builder::DeviceAccessTokenRequest { + Default::default() + } + } + + ///`DeviceAuthRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DeviceAuthRequest { + pub client_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&DeviceAuthRequest> for DeviceAuthRequest { + fn from(value: &DeviceAuthRequest) -> Self { + value.clone() + } + } + + impl DeviceAuthRequest { + pub fn builder() -> builder::DeviceAuthRequest { + Default::default() + } + } + + ///`DeviceAuthVerify` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "user_code" + /// ], + /// "properties": { + /// "user_code": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DeviceAuthVerify { + pub user_code: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAuthVerify> for DeviceAuthVerify { + fn from(value: &DeviceAuthVerify) -> Self { + value.clone() + } + } + + impl DeviceAuthVerify { + pub fn builder() -> builder::DeviceAuthVerify { + Default::default() + } + } + + ///`Digest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "sha256" + /// ] + /// }, + /// "value": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "value")] + pub enum Digest { + #[serde(rename = "sha256")] + Sha256(::std::string::String), + } + + impl ::std::convert::From<&Self> for Digest { + fn from(value: &Digest) -> Self { + value.clone() + } + } + + ///Client view of a [`Disk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Disk`]", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "device_path", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "device_path": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "snapshot_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Disk { + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub device_path: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub image_id: ::std::option::Option<::uuid::Uuid>, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub snapshot_id: ::std::option::Option<::uuid::Uuid>, + pub state: DiskState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Disk> for Disk { + fn from(value: &Disk) -> Self { + value.clone() + } + } + + impl Disk { + pub fn builder() -> builder::Disk { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskCreate { + pub description: ::std::string::String, + ///initial source for this disk + pub disk_source: DiskSource, + pub name: Name, + ///total size of the Disk in bytes + pub size: ByteCount, + } + + impl ::std::convert::From<&DiskCreate> for DiskCreate { + fn from(value: &DiskCreate) -> Self { + value.clone() + } + } + + impl DiskCreate { + pub fn builder() -> builder::DiskCreate { + Default::default() + } + } + + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance", + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskIdentifier { + pub name: Name, + } + + impl ::std::convert::From<&DiskIdentifier> for DiskIdentifier { + fn from(value: &DiskIdentifier) -> Self { + value.clone() + } + } + + impl DiskIdentifier { + pub fn builder() -> builder::DiskIdentifier { + Default::default() + } + } + + ///`DiskMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "activated", + /// "flush", + /// "read", + /// "read_bytes", + /// "write", + /// "write_bytes" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum DiskMetricName { + #[serde(rename = "activated")] + Activated, + #[serde(rename = "flush")] + Flush, + #[serde(rename = "read")] + Read, + #[serde(rename = "read_bytes")] + ReadBytes, + #[serde(rename = "write")] + Write, + #[serde(rename = "write_bytes")] + WriteBytes, + } + + impl ::std::convert::From<&Self> for DiskMetricName { + fn from(value: &DiskMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DiskMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Activated => f.write_str("activated"), + Self::Flush => f.write_str("flush"), + Self::Read => f.write_str("read"), + Self::ReadBytes => f.write_str("read_bytes"), + Self::Write => f.write_str("write"), + Self::WriteBytes => f.write_str("write_bytes"), + } + } + } + + impl ::std::str::FromStr for DiskMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "activated" => Ok(Self::Activated), + "flush" => Ok(Self::Flush), + "read" => Ok(Self::Read), + "read_bytes" => Ok(Self::ReadBytes), + "write" => Ok(Self::Write), + "write_bytes" => Ok(Self::WriteBytes), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DiskPath` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk" + /// ], + /// "properties": { + /// "disk": { + /// "$ref": "#/components/schemas/NameOrId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskPath { + pub disk: NameOrId, + } + + impl ::std::convert::From<&DiskPath> for DiskPath { + fn from(value: &DiskPath) -> Self { + value.clone() + } + } + + impl DiskPath { + pub fn builder() -> builder::DiskPath { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Disk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&DiskResultsPage> for DiskResultsPage { + fn from(value: &DiskResultsPage) -> Self { + value.clone() + } + } + + impl DiskResultsPage { + pub fn builder() -> builder::DiskResultsPage { + Default::default() + } + } + + ///Different sources for a disk + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Different sources for a disk", + /// "oneOf": [ + /// { + /// "description": "Create a blank disk", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks for this Disk. valid values are: + /// 512, 2048, or 4096", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "blank" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a disk snapshot", + /// "type": "object", + /// "required": [ + /// "snapshot_id", + /// "type" + /// ], + /// "properties": { + /// "snapshot_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a project image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "image" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a global image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "global_image" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum DiskSource { + ///Create a blank disk + #[serde(rename = "blank")] + Blank { + ///size of blocks for this Disk. valid values are: 512, 2048, or + /// 4096 + block_size: BlockSize, + }, + ///Create a disk from a disk snapshot + #[serde(rename = "snapshot")] + Snapshot { snapshot_id: ::uuid::Uuid }, + ///Create a disk from a project image + #[serde(rename = "image")] + Image { image_id: ::uuid::Uuid }, + ///Create a disk from a global image + #[serde(rename = "global_image")] + GlobalImage { image_id: ::uuid::Uuid }, + } + + impl ::std::convert::From<&Self> for DiskSource { + fn from(value: &DiskSource) -> Self { + value.clone() + } + } + + ///State of a Disk (primarily: attached or not) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "State of a Disk (primarily: attached or not)", + /// "oneOf": [ + /// { + /// "description": "Disk is being initialized", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is ready but detached from any Instance", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being detached from the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk has been destroyed", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is unavailable", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "faulted" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "state", content = "instance")] + pub enum DiskState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "detached")] + Detached, + ///Disk is being attached to the given Instance + #[serde(rename = "attaching")] + Attaching(::uuid::Uuid), + ///Disk is attached to the given Instance + #[serde(rename = "attached")] + Attached(::uuid::Uuid), + ///Disk is being detached from the given Instance + #[serde(rename = "detaching")] + Detaching(::uuid::Uuid), + #[serde(rename = "destroyed")] + Destroyed, + #[serde(rename = "faulted")] + Faulted, + } + + impl ::std::convert::From<&Self> for DiskState { + fn from(value: &DiskState) -> Self { + value.clone() + } + } + + ///OS image distribution + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "OS image distribution", + /// "type": "object", + /// "required": [ + /// "name", + /// "version" + /// ], + /// "properties": { + /// "name": { + /// "description": "The name of the distribution (e.g. \"alpine\" or + /// \"ubuntu\")", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "version": { + /// "description": "The version of the distribution (e.g. \"3.10\" or + /// \"18.04\")", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Distribution { + ///The name of the distribution (e.g. "alpine" or "ubuntu") + pub name: Name, + ///The version of the distribution (e.g. "3.10" or "18.04") + pub version: ::std::string::String, + } + + impl ::std::convert::From<&Distribution> for Distribution { + fn from(value: &Distribution) -> Self { + value.clone() + } + } + + impl Distribution { + pub fn builder() -> builder::Distribution { + Default::default() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + impl Error { + pub fn builder() -> builder::Error { + Default::default() + } + } + + ///`ExternalIp` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "ip", + /// "kind" + /// ], + /// "properties": { + /// "ip": { + /// "type": "string", + /// "format": "ip" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/IpKind" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ExternalIp { + pub ip: ::std::net::IpAddr, + pub kind: IpKind, + } + + impl ::std::convert::From<&ExternalIp> for ExternalIp { + fn from(value: &ExternalIp) -> Self { + value.clone() + } + } + + impl ExternalIp { + pub fn builder() -> builder::ExternalIp { + Default::default() + } + } + + ///Parameters for creating an external IP address for instances. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for creating an external IP address for + /// instances.", + /// "oneOf": [ + /// { + /// "description": "An IP address providing both inbound and outbound + /// access. The address is automatically-assigned from the provided IP Pool, + /// or all available pools if not specified.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "pool_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ephemeral" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum ExternalIpCreate { + ///An IP address providing both inbound and outbound access. The + /// address is automatically-assigned from the provided IP Pool, or all + /// available pools if not specified. + #[serde(rename = "ephemeral")] + Ephemeral { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pool_name: ::std::option::Option, + }, + } + + impl ::std::convert::From<&Self> for ExternalIpCreate { + fn from(value: &ExternalIpCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIp" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ExternalIpResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ExternalIpResultsPage> for ExternalIpResultsPage { + fn from(value: &ExternalIpResultsPage) -> Self { + value.clone() + } + } + + impl ExternalIpResultsPage { + pub fn builder() -> builder::ExternalIpResultsPage { + Default::default() + } + } + + ///The name and type information for a field of a timeseries schema. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The name and type information for a field of a + /// timeseries schema.", + /// "type": "object", + /// "required": [ + /// "name", + /// "source", + /// "ty" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "source": { + /// "$ref": "#/components/schemas/FieldSource" + /// }, + /// "ty": { + /// "$ref": "#/components/schemas/FieldType" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct FieldSchema { + pub name: ::std::string::String, + pub source: FieldSource, + pub ty: FieldType, + } + + impl ::std::convert::From<&FieldSchema> for FieldSchema { + fn from(value: &FieldSchema) -> Self { + value.clone() + } + } + + impl FieldSchema { + pub fn builder() -> builder::FieldSchema { + Default::default() + } + } + + ///The source from which a field is derived, the target or metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source from which a field is derived, the target or + /// metric.", + /// "type": "string", + /// "enum": [ + /// "target", + /// "metric" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum FieldSource { + #[serde(rename = "target")] + Target, + #[serde(rename = "metric")] + Metric, + } + + impl ::std::convert::From<&Self> for FieldSource { + fn from(value: &FieldSource) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Target => f.write_str("target"), + Self::Metric => f.write_str("metric"), + } + } + } + + impl ::std::str::FromStr for FieldSource { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "target" => Ok(Self::Target), + "metric" => Ok(Self::Metric), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldSource { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The `FieldType` identifies the data type of a target or metric field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `FieldType` identifies the data type of a target or + /// metric field.", + /// "type": "string", + /// "enum": [ + /// "string", + /// "i64", + /// "ip_addr", + /// "uuid", + /// "bool" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum FieldType { + #[serde(rename = "string")] + String, + #[serde(rename = "i64")] + I64, + #[serde(rename = "ip_addr")] + IpAddr, + #[serde(rename = "uuid")] + Uuid, + #[serde(rename = "bool")] + Bool, + } + + impl ::std::convert::From<&Self> for FieldType { + fn from(value: &FieldType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::String => f.write_str("string"), + Self::I64 => f.write_str("i64"), + Self::IpAddr => f.write_str("ip_addr"), + Self::Uuid => f.write_str("uuid"), + Self::Bool => f.write_str("bool"), + } + } + } + + impl ::std::str::FromStr for FieldType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "string" => Ok(Self::String), + "i64" => Ok(Self::I64), + "ip_addr" => Ok(Self::IpAddr), + "uuid" => Ok(Self::Uuid), + "bool" => Ok(Self::Bool), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`FleetRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum FleetRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for FleetRole { + fn from(value: &FleetRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FleetRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for FleetRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FleetRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FleetRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct FleetRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&FleetRolePolicy> for FleetRolePolicy { + fn from(value: &FleetRolePolicy) -> Self { + value.clone() + } + } + + impl FleetRolePolicy { + pub fn builder() -> builder::FleetRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/FleetRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct FleetRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: FleetRole, + } + + impl ::std::convert::From<&FleetRoleRoleAssignment> for FleetRoleRoleAssignment { + fn from(value: &FleetRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl FleetRoleRoleAssignment { + pub fn builder() -> builder::FleetRoleRoleAssignment { + Default::default() + } + } + + ///Client view of global Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of global Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "id", + /// "name", + /// "size", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "distribution": { + /// "description": "Image distribution", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Image version", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct GlobalImage { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///Image distribution + pub distribution: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Image version + pub version: ::std::string::String, + } + + impl ::std::convert::From<&GlobalImage> for GlobalImage { + fn from(value: &GlobalImage) -> Self { + value.clone() + } + } + + impl GlobalImage { + pub fn builder() -> builder::GlobalImage { + Default::default() + } + } + + ///Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "distribution": { + /// "description": "OS image distribution", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Distribution" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct GlobalImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + ///OS image distribution + pub distribution: Distribution, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&GlobalImageCreate> for GlobalImageCreate { + fn from(value: &GlobalImageCreate) -> Self { + value.clone() + } + } + + impl GlobalImageCreate { + pub fn builder() -> builder::GlobalImageCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/GlobalImage" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct GlobalImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GlobalImageResultsPage> for GlobalImageResultsPage { + fn from(value: &GlobalImageResultsPage) -> Self { + value.clone() + } + } + + impl GlobalImageResultsPage { + pub fn builder() -> builder::GlobalImageResultsPage { + Default::default() + } + } + + ///Client view of a [`Group`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Group`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the group", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this group belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&Group> for Group { + fn from(value: &Group) -> Self { + value.clone() + } + } + + impl Group { + pub fn builder() -> builder::Group { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Group" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GroupResultsPage> for GroupResultsPage { + fn from(value: &GroupResultsPage) -> Self { + value.clone() + } + } + + impl GroupResultsPage { + pub fn builder() -> builder::GroupResultsPage { + Default::default() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Bindouble" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Histogramdouble { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramdouble> for Histogramdouble { + fn from(value: &Histogramdouble) -> Self { + value.clone() + } + } + + impl Histogramdouble { + pub fn builder() -> builder::Histogramdouble { + Default::default() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Binint64" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Histogramint64 { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramint64> for Histogramint64 { + fn from(value: &Histogramint64) -> Self { + value.clone() + } + } + + impl Histogramint64 { + pub fn builder() -> builder::Histogramint64 { + Default::default() + } + } + + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by id + /// only.\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum IdSortMode { + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for IdSortMode { + fn from(value: &IdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for IdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of an [`IdentityProvider`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`IdentityProvider`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "provider_type", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "provider_type": { + /// "description": "Identity provider type", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdentityProviderType" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IdentityProvider { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///Identity provider type + pub provider_type: IdentityProviderType, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IdentityProvider> for IdentityProvider { + fn from(value: &IdentityProvider) -> Self { + value.clone() + } + } + + impl IdentityProvider { + pub fn builder() -> builder::IdentityProvider { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IdentityProvider" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IdentityProviderResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IdentityProviderResultsPage> for IdentityProviderResultsPage { + fn from(value: &IdentityProviderResultsPage) -> Self { + value.clone() + } + } + + impl IdentityProviderResultsPage { + pub fn builder() -> builder::IdentityProviderResultsPage { + Default::default() + } + } + + ///`IdentityProviderType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "description": "SAML identity provider", + /// "type": "string", + /// "enum": [ + /// "saml" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum IdentityProviderType { + ///SAML identity provider + #[serde(rename = "saml")] + Saml, + } + + impl ::std::convert::From<&Self> for IdentityProviderType { + fn from(value: &IdentityProviderType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityProviderType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Saml => f.write_str("saml"), + } + } + } + + impl ::std::str::FromStr for IdentityProviderType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml" => Ok(Self::Saml), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Describes what kind of identity is described by an id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes what kind of identity is described by an id", + /// "type": "string", + /// "enum": [ + /// "silo_user", + /// "silo_group" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum IdentityType { + #[serde(rename = "silo_user")] + SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, + } + + impl ::std::convert::From<&Self> for IdentityType { + fn from(value: &IdentityType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SiloUser => f.write_str("silo_user"), + Self::SiloGroup => f.write_str("silo_group"), + } + } + } + + impl ::std::str::FromStr for IdentityType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IdpMetadataSource` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "data", + /// "type" + /// ], + /// "properties": { + /// "data": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "base64_encoded_xml" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum IdpMetadataSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "base64_encoded_xml")] + Base64EncodedXml { data: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for IdpMetadataSource { + fn from(value: &IdpMetadataSource) -> Self { + value.clone() + } + } + + ///Client view of project Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of project Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "The project the disk belongs to", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Version of this, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Image { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///The project the disk belongs to + pub project_id: ::uuid::Uuid, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Version of this, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub version: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&Image> for Image { + fn from(value: &Image) -> Self { + value.clone() + } + } + + impl Image { + pub fn builder() -> builder::Image { + Default::default() + } + } + + ///Create-time parameters for an + /// [`Image`](crate::external_api::views::Image) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Image`](crate::external_api::views::Image)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&ImageCreate> for ImageCreate { + fn from(value: &ImageCreate) -> Self { + value.clone() + } + } + + impl ImageCreate { + pub fn builder() -> builder::ImageCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Image" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ImageResultsPage> for ImageResultsPage { + fn from(value: &ImageResultsPage) -> Self { + value.clone() + } + } + + impl ImageResultsPage { + pub fn builder() -> builder::ImageResultsPage { + Default::default() + } + } + + ///The source of the underlying image. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source of the underlying image.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "id", + /// "type" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Boot the Alpine ISO that ships with the Propolis + /// zone. Intended for development purposes only.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "you_can_boot_anything_as_long_as_its_alpine" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum ImageSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "snapshot")] + Snapshot { id: ::uuid::Uuid }, + #[serde(rename = "you_can_boot_anything_as_long_as_its_alpine")] + YouCanBootAnythingAsLongAsItsAlpine, + } + + impl ::std::convert::From<&Self> for ImageSource { + fn from(value: &ImageSource) -> Self { + value.clone() + } + } + + ///Client view of an [`Instance`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Instance`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "id", + /// "memory", + /// "name", + /// "ncpus", + /// "project_id", + /// "run_state", + /// "time_created", + /// "time_modified", + /// "time_run_state_updated" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "hostname": { + /// "description": "RFC1035-compliant hostname for the Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "memory allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "ncpus": { + /// "description": "number of CPUs allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this Instance", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "run_state": { + /// "$ref": "#/components/schemas/InstanceState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_run_state_updated": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Instance { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///RFC1035-compliant hostname for the Instance. + pub hostname: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///memory allocated for this Instance + pub memory: ByteCount, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///number of CPUs allocated for this Instance + pub ncpus: InstanceCpuCount, + ///id for the project containing this Instance + pub project_id: ::uuid::Uuid, + pub run_state: InstanceState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub time_run_state_updated: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + impl Instance { + pub fn builder() -> builder::Instance { + Default::default() + } + } + + ///The number of CPUs in an Instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The number of CPUs in an Instance", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct InstanceCpuCount(pub u16); + impl ::std::ops::Deref for InstanceCpuCount { + type Target = u16; + fn deref(&self) -> &u16 { + &self.0 + } + } + + impl ::std::convert::From for u16 { + fn from(value: InstanceCpuCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&InstanceCpuCount> for InstanceCpuCount { + fn from(value: &InstanceCpuCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for InstanceCpuCount { + fn from(value: u16) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for InstanceCpuCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for InstanceCpuCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "memory", + /// "name", + /// "ncpus" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disks": { + /// "description": "The disks to be created or attached for this + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/InstanceDiskAttachment" + /// } + /// }, + /// "external_ips": { + /// "description": "The external IP addresses provided to this + /// instance.\n\nBy default, all instances have outbound connectivity, but + /// no inbound connectivity. These external addresses can be used to provide + /// a fixed, known IP address for making inbound connections to the + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIpCreate" + /// } + /// }, + /// "hostname": { + /// "type": "string" + /// }, + /// "memory": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ncpus": { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// }, + /// "network_interfaces": { + /// "description": "The network interfaces to be created for this + /// instance.", + /// "default": { + /// "type": "default" + /// }, + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceNetworkInterfaceAttachment" + /// } + /// ] + /// }, + /// "start": { + /// "description": "Should this instance be started upon creation; true + /// by default.", + /// "default": true, + /// "type": "boolean" + /// }, + /// "user_data": { + /// "description": "User data for instance initialization systems (such + /// as cloud-init). Must be a Base64-encoded string, as specified in RFC + /// 4648 § 4 (+ and / characters with padding). Maximum 32 KiB unencoded + /// data.", + /// "default": "", + /// "type": "string", + /// "format": "byte" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceCreate { + pub description: ::std::string::String, + ///The disks to be created or attached for this instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + ///The external IP addresses provided to this instance. + /// + ///By default, all instances have outbound connectivity, but no inbound + /// connectivity. These external addresses can be used to provide a + /// fixed, known IP address for making inbound connections to the + /// instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub external_ips: ::std::vec::Vec, + pub hostname: ::std::string::String, + pub memory: ByteCount, + pub name: Name, + pub ncpus: InstanceCpuCount, + ///The network interfaces to be created for this instance. + #[serde(default = "defaults::instance_create_network_interfaces")] + pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, + ///User data for instance initialization systems (such as cloud-init). + /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and + /// / characters with padding). Maximum 32 KiB unencoded data. + #[serde(default)] + pub user_data: ::std::string::String, + } + + impl ::std::convert::From<&InstanceCreate> for InstanceCreate { + fn from(value: &InstanceCreate) -> Self { + value.clone() + } + } + + impl InstanceCreate { + pub fn builder() -> builder::InstanceCreate { + Default::default() + } + } + + ///Describe the instance's disks at creation time + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describe the instance's disks at creation time", + /// "oneOf": [ + /// { + /// "description": "During instance creation, create and attach disks", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size", + /// "type" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "During instance creation, attach this disk", + /// "type": "object", + /// "required": [ + /// "name", + /// "type" + /// ], + /// "properties": { + /// "name": { + /// "description": "A disk name to attach", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "attach" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum InstanceDiskAttachment { + ///During instance creation, create and attach disks + #[serde(rename = "create")] + Create { + description: ::std::string::String, + ///initial source for this disk + disk_source: DiskSource, + name: Name, + ///total size of the Disk in bytes + size: ByteCount, + }, + ///During instance creation, attach this disk + #[serde(rename = "attach")] + Attach { + ///A disk name to attach + name: Name, + }, + } + + impl ::std::convert::From<&Self> for InstanceDiskAttachment { + fn from(value: &InstanceDiskAttachment) -> Self { + value.clone() + } + } + + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "dst_sled_id" + /// ], + /// "properties": { + /// "dst_sled_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceMigrate { + pub dst_sled_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrate> for InstanceMigrate { + fn from(value: &InstanceMigrate) -> Self { + value.clone() + } + } + + impl InstanceMigrate { + pub fn builder() -> builder::InstanceMigrate { + Default::default() + } + } + + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes an attachment of a `NetworkInterface` to an + /// `Instance`, at the time the instance is created.", + /// "oneOf": [ + /// { + /// "description": "Create one or more `NetworkInterface`s for the + /// `Instance`.\n\nIf more than one interface is provided, then the first + /// will be designated the primary interface for the instance.", + /// "type": "object", + /// "required": [ + /// "params", + /// "type" + /// ], + /// "properties": { + /// "params": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceCreate" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "The default networking configuration for an + /// instance is to create a single primary interface with an + /// automatically-assigned IP address. The IP will be pulled from the + /// Project's default VPC / VPC Subnet.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "No network interfaces at all will be created for + /// the instance.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "none" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "params")] + pub enum InstanceNetworkInterfaceAttachment { + ///Create one or more `NetworkInterface`s for the `Instance`. + /// + ///If more than one interface is provided, then the first will be + /// designated the primary interface for the instance. + #[serde(rename = "create")] + Create(::std::vec::Vec), + #[serde(rename = "default")] + Default, + #[serde(rename = "none")] + None, + } + + impl ::std::convert::From<&Self> for InstanceNetworkInterfaceAttachment { + fn from(value: &InstanceNetworkInterfaceAttachment) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec> + for InstanceNetworkInterfaceAttachment + { + fn from(value: ::std::vec::Vec) -> Self { + Self::Create(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&InstanceResultsPage> for InstanceResultsPage { + fn from(value: &InstanceResultsPage) -> Self { + value.clone() + } + } + + impl InstanceResultsPage { + pub fn builder() -> builder::InstanceResultsPage { + Default::default() + } + } + + ///Contents of an Instance's serial console buffer. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Contents of an Instance's serial console buffer.", + /// "type": "object", + /// "required": [ + /// "data", + /// "last_byte_offset" + /// ], + /// "properties": { + /// "data": { + /// "description": "The bytes starting from the requested offset up to + /// either the end of the buffer or the request's `max_bytes`. Provided as a + /// u8 array rather than a string, as it may not be UTF-8.", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "last_byte_offset": { + /// "description": "The absolute offset since boot (suitable for use as + /// `byte_offset` in a subsequent request) of the last byte returned in + /// `data`.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceSerialConsoleData { + ///The bytes starting from the requested offset up to either the end of + /// the buffer or the request's `max_bytes`. Provided as a u8 array + /// rather than a string, as it may not be UTF-8. + pub data: ::std::vec::Vec, + ///The absolute offset since boot (suitable for use as `byte_offset` in + /// a subsequent request) of the last byte returned in `data`. + pub last_byte_offset: u64, + } + + impl ::std::convert::From<&InstanceSerialConsoleData> for InstanceSerialConsoleData { + fn from(value: &InstanceSerialConsoleData) -> Self { + value.clone() + } + } + + impl InstanceSerialConsoleData { + pub fn builder() -> builder::InstanceSerialConsoleData { + Default::default() + } + } + + ///Running state of an Instance (primarily: booted or stopped) + /// + ///This typically reflects whether it's starting, running, stopping, or + /// stopped, but also includes states related to the Instance's lifecycle + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Running state of an Instance (primarily: booted or + /// stopped)\n\nThis typically reflects whether it's starting, running, + /// stopping, or stopped, but also includes states related to the Instance's + /// lifecycle", + /// "oneOf": [ + /// { + /// "description": "The instance is being created.", + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// }, + /// { + /// "description": "The instance is currently starting up.", + /// "type": "string", + /// "enum": [ + /// "starting" + /// ] + /// }, + /// { + /// "description": "The instance is currently running.", + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// }, + /// { + /// "description": "The instance has been requested to stop and a + /// transition to \"Stopped\" is imminent.", + /// "type": "string", + /// "enum": [ + /// "stopping" + /// ] + /// }, + /// { + /// "description": "The instance is currently stopped.", + /// "type": "string", + /// "enum": [ + /// "stopped" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of rebooting - it + /// will remain in the \"rebooting\" state until the VM is starting once + /// more.", + /// "type": "string", + /// "enum": [ + /// "rebooting" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of migrating - it will remain in the \"migrating\" state until the migration process is complete and the destination propolis is ready to continue execution.", + /// "type": "string", + /// "enum": [ + /// "migrating" + /// ] + /// }, + /// { + /// "description": "The instance is attempting to recover from a + /// failure.", + /// "type": "string", + /// "enum": [ + /// "repairing" + /// ] + /// }, + /// { + /// "description": "The instance has encountered a failure.", + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// }, + /// { + /// "description": "The instance has been deleted.", + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum InstanceState { + ///The instance is being created. + #[serde(rename = "creating")] + Creating, + ///The instance is currently starting up. + #[serde(rename = "starting")] + Starting, + ///The instance is currently running. + #[serde(rename = "running")] + Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. + #[serde(rename = "stopping")] + Stopping, + ///The instance is currently stopped. + #[serde(rename = "stopped")] + Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. + #[serde(rename = "rebooting")] + Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. + #[serde(rename = "migrating")] + Migrating, + ///The instance is attempting to recover from a failure. + #[serde(rename = "repairing")] + Repairing, + ///The instance has encountered a failure. + #[serde(rename = "failed")] + Failed, + ///The instance has been deleted. + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Starting => f.write_str("starting"), + Self::Running => f.write_str("running"), + Self::Stopping => f.write_str("stopping"), + Self::Stopped => f.write_str("stopped"), + Self::Rebooting => f.write_str("rebooting"), + Self::Migrating => f.write_str("migrating"), + Self::Repairing => f.write_str("repairing"), + Self::Failed => f.write_str("failed"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "starting" => Ok(Self::Starting), + "running" => Ok(Self::Running), + "stopping" => Ok(Self::Stopping), + "stopped" => Ok(Self::Stopped), + "rebooting" => Ok(Self::Rebooting), + "migrating" => Ok(Self::Migrating), + "repairing" => Ok(Self::Repairing), + "failed" => Ok(Self::Failed), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The kind of an external IP address for an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The kind of an external IP address for an instance", + /// "type": "string", + /// "enum": [ + /// "ephemeral", + /// "floating" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum IpKind { + #[serde(rename = "ephemeral")] + Ephemeral, + #[serde(rename = "floating")] + Floating, + } + + impl ::std::convert::From<&Self> for IpKind { + fn from(value: &IpKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IpKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Ephemeral => f.write_str("ephemeral"), + Self::Floating => f.write_str("floating"), + } + } + } + + impl ::std::str::FromStr for IpKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "ephemeral" => Ok(Self::Ephemeral), + "floating" => Ok(Self::Floating), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IpKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IpNet` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(untagged)] + pub enum IpNet { + V4(Ipv4Net), + V6(Ipv6Net), + } + + impl ::std::convert::From<&Self> for IpNet { + fn from(value: &IpNet) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for IpNet { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::V4(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::V6(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for IpNet { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for IpNet { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::V4(x) => x.fmt(f), + Self::V6(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv4Net) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv6Net) -> Self { + Self::V6(value) + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPool { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPool> for IpPool { + fn from(value: &IpPool) -> Self { + value.clone() + } + } + + impl IpPool { + pub fn builder() -> builder::IpPool { + Default::default() + } + } + + ///Create-time parameters for an IP Pool. + /// + ///See [`IpPool`](crate::external_api::views::IpPool) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an IP Pool.\n\nSee + /// [`IpPool`](crate::external_api::views::IpPool)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPoolCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&IpPoolCreate> for IpPoolCreate { + fn from(value: &IpPoolCreate) -> Self { + value.clone() + } + } + + impl IpPoolCreate { + pub fn builder() -> builder::IpPoolCreate { + Default::default() + } + } + + ///`IpPoolRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "range", + /// "time_created" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "range": { + /// "$ref": "#/components/schemas/IpRange" + /// }, + /// "time_created": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPoolRange { + pub id: ::uuid::Uuid, + pub range: IpRange, + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPoolRange> for IpPoolRange { + fn from(value: &IpPoolRange) -> Self { + value.clone() + } + } + + impl IpPoolRange { + pub fn builder() -> builder::IpPoolRange { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPoolRange" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPoolRangeResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolRangeResultsPage> for IpPoolRangeResultsPage { + fn from(value: &IpPoolRangeResultsPage) -> Self { + value.clone() + } + } + + impl IpPoolRangeResultsPage { + pub fn builder() -> builder::IpPoolRangeResultsPage { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPool" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPoolResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolResultsPage> for IpPoolResultsPage { + fn from(value: &IpPoolResultsPage) -> Self { + value.clone() + } + } + + impl IpPoolResultsPage { + pub fn builder() -> builder::IpPoolResultsPage { + Default::default() + } + } + + ///Parameters for updating an IP Pool + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating an IP Pool", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct IpPoolUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&IpPoolUpdate> for IpPoolUpdate { + fn from(value: &IpPoolUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for IpPoolUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl IpPoolUpdate { + pub fn builder() -> builder::IpPoolUpdate { + Default::default() + } + } + + ///`IpRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Range" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Range" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(untagged)] + pub enum IpRange { + V4(Ipv4Range), + V6(Ipv6Range), + } + + impl ::std::convert::From<&Self> for IpRange { + fn from(value: &IpRange) -> Self { + value.clone() + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv4Range) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv6Range) -> Self { + Self::V6(value) + } + } + + ///An IPv4 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv4 subnet", + /// "description": "An IPv4 subnet, including prefix and subnet mask", + /// "examples": [ + /// "192.168.1.0/24" + /// ], + /// "type": "string", + /// "pattern": + /// "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\. + /// ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/ + /// ([8-9]|1[0-9]|2[0-9]|3[0-2])$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct Ipv4Net(::std::string::String); + impl ::std::ops::Deref for Ipv4Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv4Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv4Net> for Ipv4Net { + fn from(value: &Ipv4Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv4Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv4Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv4 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv4 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv4" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv4" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Ipv4Range { + pub first: ::std::net::Ipv4Addr, + pub last: ::std::net::Ipv4Addr, + } + + impl ::std::convert::From<&Ipv4Range> for Ipv4Range { + fn from(value: &Ipv4Range) -> Self { + value.clone() + } + } + + impl Ipv4Range { + pub fn builder() -> builder::Ipv4Range { + Default::default() + } + } + + ///An IPv6 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv6 subnet", + /// "description": "An IPv6 subnet, including prefix and subnet mask", + /// "examples": [ + /// "fd12:3456::/64" + /// ], + /// "type": "string", + /// "pattern": + /// "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1, + /// 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct Ipv6Net(::std::string::String); + impl ::std::ops::Deref for Ipv6Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv6Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv6Net> for Ipv6Net { + fn from(value: &Ipv6Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv6Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv6Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv6 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv6 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv6" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv6" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Ipv6Range { + pub first: ::std::net::Ipv6Addr, + pub last: ::std::net::Ipv6Addr, + } + + impl ::std::convert::From<&Ipv6Range> for Ipv6Range { + fn from(value: &Ipv6Range) -> Self { + value.clone() + } + } + + impl Ipv6Range { + pub fn builder() -> builder::Ipv6Range { + Default::default() + } + } + + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A range of IP ports", + /// "description": "An inclusive-inclusive range of IP ports. The second + /// port may be omitted to represent a single port", + /// "examples": [ + /// "22" + /// ], + /// "type": "string", + /// "maxLength": 11, + /// "minLength": 1, + /// "pattern": "^[0-9]{1,5}(-[0-9]{1,5})?$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct L4PortRange(::std::string::String); + impl ::std::ops::Deref for L4PortRange { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: L4PortRange) -> Self { + value.0 + } + } + + impl ::std::convert::From<&L4PortRange> for L4PortRange { + fn from(value: &L4PortRange) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for L4PortRange { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 11usize { + return Err("longer than 11 characters".into()); + } + if value.chars().count() < 1usize { + return Err("shorter than 1 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for L4PortRange { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A Media Access Control address, in EUI-48 format + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A MAC address", + /// "description": "A Media Access Control address, in EUI-48 format", + /// "examples": [ + /// "ff:ff:ff:ff:ff:ff" + /// ], + /// "type": "string", + /// "maxLength": 17, + /// "minLength": 17, + /// "pattern": "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct MacAddr(::std::string::String); + impl ::std::ops::Deref for MacAddr { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: MacAddr) -> Self { + value.0 + } + } + + impl ::std::convert::From<&MacAddr> for MacAddr { + fn from(value: &MacAddr) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for MacAddr { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 17usize { + return Err("longer than 17 characters".into()); + } + if value.chars().count() < 17usize { + return Err("shorter than 17 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for MacAddr { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for MacAddr { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A `Measurement` is a timestamped datum from a single metric + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Measurement` is a timestamped datum from a single + /// metric", + /// "type": "object", + /// "required": [ + /// "datum", + /// "timestamp" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Datum" + /// }, + /// "timestamp": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Measurement { + pub datum: Datum, + pub timestamp: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Measurement> for Measurement { + fn from(value: &Measurement) -> Self { + value.clone() + } + } + + impl Measurement { + pub fn builder() -> builder::Measurement { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Measurement" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct MeasurementResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&MeasurementResultsPage> for MeasurementResultsPage { + fn from(value: &MeasurementResultsPage) -> Self { + value.clone() + } + } + + impl MeasurementResultsPage { + pub fn builder() -> builder::MeasurementResultsPage { + Default::default() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct Name(::std::string::String); + impl ::std::ops::Deref for Name { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Name) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Name> for Name { + fn from(value: &Name) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Name { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Name { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Name { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///`NameOrId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "id", + /// "allOf": [ + /// { + /// "type": "string", + /// "format": "uuid" + /// } + /// ] + /// }, + /// { + /// "title": "name", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(untagged)] + pub enum NameOrId { + Id(::uuid::Uuid), + Name(Name), + } + + impl ::std::convert::From<&Self> for NameOrId { + fn from(value: &NameOrId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for NameOrId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for NameOrId { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::Id(x) => x.fmt(f), + Self::Name(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From<::uuid::Uuid> for NameOrId { + fn from(value: ::uuid::Uuid) -> Self { + Self::Id(value) + } + } + + impl ::std::convert::From for NameOrId { + fn from(value: Name) -> Self { + Self::Name(value) + } + } + + ///Supported set of sort modes for scanning by name or id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name or + /// id", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// }, + /// { + /// "description": "sort in decreasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_descending" + /// ] + /// }, + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum NameOrIdSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + ///sort in decreasing order of "name" + #[serde(rename = "name_descending")] + NameDescending, + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for NameOrIdSortMode { + fn from(value: &NameOrIdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameOrIdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + Self::NameDescending => f.write_str("name_descending"), + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for NameOrIdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + "name_descending" => Ok(Self::NameDescending), + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name + /// only\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum NameSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + } + + impl ::std::convert::From<&Self> for NameSortMode { + fn from(value: &NameSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + } + } + } + + impl ::std::str::FromStr for NameSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `NetworkInterface` represents a virtual network interface device. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `NetworkInterface` represents a virtual network + /// interface device.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "instance_id", + /// "ip", + /// "mac", + /// "name", + /// "primary", + /// "subnet_id", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "instance_id": { + /// "description": "The Instance to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ip": { + /// "description": "The IP address assigned to this interface.", + /// "type": "string", + /// "format": "ip" + /// }, + /// "mac": { + /// "description": "The MAC address assigned to this interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/MacAddr" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "primary": { + /// "description": "True if this interface is the primary for the + /// instance to which it's attached.", + /// "type": "boolean" + /// }, + /// "subnet_id": { + /// "description": "The subnet to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterface { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The Instance to which the interface belongs. + pub instance_id: ::uuid::Uuid, + ///The IP address assigned to this interface. + pub ip: ::std::net::IpAddr, + ///The MAC address assigned to this interface. + pub mac: MacAddr, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///True if this interface is the primary for the instance to which it's + /// attached. + pub primary: bool, + ///The subnet to which the interface belongs. + pub subnet_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the interface belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + impl NetworkInterface { + pub fn builder() -> builder::NetworkInterface { + Default::default() + } + } + + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`NetworkInterface`](omicron_common::api::external::NetworkInterface)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "subnet_name", + /// "vpc_name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ip": { + /// "description": "The IP address for the interface. One will be + /// auto-assigned if not provided.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "ip" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "subnet_name": { + /// "description": "The VPC Subnet in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "vpc_name": { + /// "description": "The VPC in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterfaceCreate { + pub description: ::std::string::String, + ///The IP address for the interface. One will be auto-assigned if not + /// provided. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ip: ::std::option::Option<::std::net::IpAddr>, + pub name: Name, + ///The VPC Subnet in which to create the interface. + pub subnet_name: Name, + ///The VPC in which to create the interface. + pub vpc_name: Name, + } + + impl ::std::convert::From<&NetworkInterfaceCreate> for NetworkInterfaceCreate { + fn from(value: &NetworkInterfaceCreate) -> Self { + value.clone() + } + } + + impl NetworkInterfaceCreate { + pub fn builder() -> builder::NetworkInterfaceCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterfaceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&NetworkInterfaceResultsPage> for NetworkInterfaceResultsPage { + fn from(value: &NetworkInterfaceResultsPage) -> Self { + value.clone() + } + } + + impl NetworkInterfaceResultsPage { + pub fn builder() -> builder::NetworkInterfaceResultsPage { + Default::default() + } + } + + ///Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface). + /// + ///Note that modifying IP addresses for an interface is not yet supported, + /// a new interface must be created instead. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface).\ + /// n\nNote that modifying IP addresses for an interface is not yet + /// supported, a new interface must be created instead.", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "primary": { + /// "description": "Make a secondary interface the instance's primary + /// interface.\n\nIf applied to a secondary interface, that interface will + /// become the primary on the next reboot of the instance. Note that this + /// may have implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface.\n\nNote that this can only be used to select a new primary + /// interface for an instance. Requests to change the primary interface into + /// a secondary will return an error.", + /// "default": false, + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterfaceUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + ///Make a secondary interface the instance's primary interface. + /// + ///If applied to a secondary interface, that interface will become the + /// primary on the next reboot of the instance. Note that this may have + /// implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface. + /// + ///Note that this can only be used to select a new primary interface + /// for an instance. Requests to change the primary interface into a + /// secondary will return an error. + #[serde(default)] + pub primary: bool, + } + + impl ::std::convert::From<&NetworkInterfaceUpdate> for NetworkInterfaceUpdate { + fn from(value: &NetworkInterfaceUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for NetworkInterfaceUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + primary: Default::default(), + } + } + } + + impl NetworkInterfaceUpdate { + pub fn builder() -> builder::NetworkInterfaceUpdate { + Default::default() + } + } + + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Unique name for a saga [`Node`]\n\nEach node requires a + /// string name that's unique within its DAG. The name is used to identify + /// its output. Nodes that depend on a given node (either directly or + /// indirectly) can access the node's output using its name.", + /// "type": "string" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct NodeName(pub ::std::string::String); + impl ::std::ops::Deref for NodeName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: NodeName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&NodeName> for NodeName { + fn from(value: &NodeName) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::string::String> for NodeName { + fn from(value: ::std::string::String) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for NodeName { + type Err = ::std::convert::Infallible; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.to_string())) + } + } + + impl ::std::fmt::Display for NodeName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of an [`Organization`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Organization`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Organization { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Organization> for Organization { + fn from(value: &Organization) -> Self { + value.clone() + } + } + + impl Organization { + pub fn builder() -> builder::Organization { + Default::default() + } + } + + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OrganizationCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&OrganizationCreate> for OrganizationCreate { + fn from(value: &OrganizationCreate) -> Self { + value.clone() + } + } + + impl OrganizationCreate { + pub fn builder() -> builder::OrganizationCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Organization" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OrganizationResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&OrganizationResultsPage> for OrganizationResultsPage { + fn from(value: &OrganizationResultsPage) -> Self { + value.clone() + } + } + + impl OrganizationResultsPage { + pub fn builder() -> builder::OrganizationResultsPage { + Default::default() + } + } + + ///`OrganizationRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum OrganizationRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for OrganizationRole { + fn from(value: &OrganizationRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for OrganizationRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for OrganizationRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/OrganizationRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OrganizationRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&OrganizationRolePolicy> for OrganizationRolePolicy { + fn from(value: &OrganizationRolePolicy) -> Self { + value.clone() + } + } + + impl OrganizationRolePolicy { + pub fn builder() -> builder::OrganizationRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/OrganizationRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OrganizationRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: OrganizationRole, + } + + impl ::std::convert::From<&OrganizationRoleRoleAssignment> for OrganizationRoleRoleAssignment { + fn from(value: &OrganizationRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl OrganizationRoleRoleAssignment { + pub fn builder() -> builder::OrganizationRoleRoleAssignment { + Default::default() + } + } + + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct OrganizationUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&OrganizationUpdate> for OrganizationUpdate { + fn from(value: &OrganizationUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for OrganizationUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl OrganizationUpdate { + pub fn builder() -> builder::OrganizationUpdate { + Default::default() + } + } + + ///Passwords may be subject to additional constraints. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A password used to authenticate a user", + /// "description": "Passwords may be subject to additional constraints.", + /// "type": "string", + /// "maxLength": 512 + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct Password(::std::string::String); + impl ::std::ops::Deref for Password { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Password) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Password> for Password { + fn from(value: &Password) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Password { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 512usize { + return Err("longer than 512 characters".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Password { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Client view of a [`PhysicalDisk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`PhysicalDisk`]", + /// "type": "object", + /// "required": [ + /// "disk_type", + /// "id", + /// "model", + /// "serial", + /// "time_created", + /// "time_modified", + /// "vendor" + /// ], + /// "properties": { + /// "disk_type": { + /// "$ref": "#/components/schemas/PhysicalDiskType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "model": { + /// "type": "string" + /// }, + /// "serial": { + /// "type": "string" + /// }, + /// "sled_id": { + /// "description": "The sled to which this disk is attached, if any.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vendor": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub model: ::std::string::String, + pub serial: ::std::string::String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sled_id: ::std::option::Option<::uuid::Uuid>, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub vendor: ::std::string::String, + } + + impl ::std::convert::From<&PhysicalDisk> for PhysicalDisk { + fn from(value: &PhysicalDisk) -> Self { + value.clone() + } + } + + impl PhysicalDisk { + pub fn builder() -> builder::PhysicalDisk { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/PhysicalDisk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&PhysicalDiskResultsPage> for PhysicalDiskResultsPage { + fn from(value: &PhysicalDiskResultsPage) -> Self { + value.clone() + } + } + + impl PhysicalDiskResultsPage { + pub fn builder() -> builder::PhysicalDiskResultsPage { + Default::default() + } + } + + ///`PhysicalDiskType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "internal", + /// "external" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ::std::convert::From<&Self> for PhysicalDiskType { + fn from(value: &PhysicalDiskType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for PhysicalDiskType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Internal => f.write_str("internal"), + Self::External => f.write_str("external"), + } + } + } + + impl ::std::str::FromStr for PhysicalDiskType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Project`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Project`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "organization_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "organization_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Project { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub organization_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Project> for Project { + fn from(value: &Project) -> Self { + value.clone() + } + } + + impl Project { + pub fn builder() -> builder::Project { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ProjectCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&ProjectCreate> for ProjectCreate { + fn from(value: &ProjectCreate) -> Self { + value.clone() + } + } + + impl ProjectCreate { + pub fn builder() -> builder::ProjectCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Project" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ProjectResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ProjectResultsPage> for ProjectResultsPage { + fn from(value: &ProjectResultsPage) -> Self { + value.clone() + } + } + + impl ProjectResultsPage { + pub fn builder() -> builder::ProjectResultsPage { + Default::default() + } + } + + ///`ProjectRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum ProjectRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for ProjectRole { + fn from(value: &ProjectRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ProjectRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for ProjectRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ProjectRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ProjectRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&ProjectRolePolicy> for ProjectRolePolicy { + fn from(value: &ProjectRolePolicy) -> Self { + value.clone() + } + } + + impl ProjectRolePolicy { + pub fn builder() -> builder::ProjectRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/ProjectRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ProjectRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: ProjectRole, + } + + impl ::std::convert::From<&ProjectRoleRoleAssignment> for ProjectRoleRoleAssignment { + fn from(value: &ProjectRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl ProjectRoleRoleAssignment { + pub fn builder() -> builder::ProjectRoleRoleAssignment { + Default::default() + } + } + + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct ProjectUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&ProjectUpdate> for ProjectUpdate { + fn from(value: &ProjectUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for ProjectUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl ProjectUpdate { + pub fn builder() -> builder::ProjectUpdate { + Default::default() + } + } + + ///Client view of an [`Rack`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Rack`]", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Rack { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Rack> for Rack { + fn from(value: &Rack) -> Self { + value.clone() + } + } + + impl Rack { + pub fn builder() -> builder::Rack { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Rack" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RackResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RackResultsPage> for RackResultsPage { + fn from(value: &RackResultsPage) -> Self { + value.clone() + } + } + + impl RackResultsPage { + pub fn builder() -> builder::RackResultsPage { + Default::default() + } + } + + ///Client view of a [`Role`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Role`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/RoleName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Role { + pub description: ::std::string::String, + pub name: RoleName, + } + + impl ::std::convert::From<&Role> for Role { + fn from(value: &Role) -> Self { + value.clone() + } + } + + impl Role { + pub fn builder() -> builder::Role { + Default::default() + } + } + + ///Role names consist of two string components separated by dot ("."). + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name for a built-in role", + /// "description": "Role names consist of two string components separated + /// by dot (\".\").", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": "[a-z-]+\\.[a-z-]+" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct RoleName(::std::string::String); + impl ::std::ops::Deref for RoleName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: RoleName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&RoleName> for RoleName { + fn from(value: &RoleName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for RoleName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| ::regress::Regex::new("[a-z-]+\\.[a-z-]+").unwrap()); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for RoleName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for RoleName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Role" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RoleResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RoleResultsPage> for RoleResultsPage { + fn from(value: &RoleResultsPage) -> Self { + value.clone() + } + } + + impl RoleResultsPage { + pub fn builder() -> builder::RoleResultsPage { + Default::default() + } + } + + ///A `RouteDestination` is used to match traffic with a routing rule, on + /// the destination of that traffic. + /// + ///When traffic is to be sent to a destination that is within a given + /// `RouteDestination`, the corresponding [`RouterRoute`] applies, and + /// traffic will be forward to the [`RouteTarget`] for that rule. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteDestination` is used to match traffic with a + /// routing rule, on the destination of that traffic.\n\nWhen traffic is to + /// be sent to a destination that is within a given `RouteDestination`, the + /// corresponding [`RouterRoute`] applies, and traffic will be forward to + /// the [`RouteTarget`] for that rule.", + /// "oneOf": [ + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for the given + /// VPC.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "value")] + pub enum RouteDestination { + ///Route applies to traffic destined for a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Route applies to traffic destined for a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + ///Route applies to traffic destined for the given VPC. + #[serde(rename = "vpc")] + Vpc(Name), + ///Route applies to traffic + #[serde(rename = "subnet")] + Subnet(Name), + } + + impl ::std::convert::From<&Self> for RouteDestination { + fn from(value: &RouteDestination) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteDestination { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for RouteDestination { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteTarget` describes the possible locations that + /// traffic matching a route destination can be sent.", + /// "oneOf": [ + /// { + /// "description": "Forward traffic to a particular IP address.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to an internet gateway", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "internet_gateway" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "value")] + pub enum RouteTarget { + ///Forward traffic to a particular IP address. + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Forward traffic to a VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///Forward traffic to a VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///Forward traffic to a specific instance + #[serde(rename = "instance")] + Instance(Name), + ///Forward traffic to an internet gateway + #[serde(rename = "internet_gateway")] + InternetGateway(Name), + } + + impl ::std::convert::From<&Self> for RouteTarget { + fn from(value: &RouteTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A route defines a rule that governs where traffic + /// should be sent based on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "id", + /// "kind", + /// "name", + /// "target", + /// "time_created", + /// "time_modified", + /// "vpc_router_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "description": "Describes the kind of router. Set at creation. + /// `read-only`", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/RouterRouteKind" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_router_id": { + /// "description": "The VPC Router to which the route belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RouterRoute { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub destination: RouteDestination, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///Describes the kind of router. Set at creation. `read-only` + pub kind: RouterRouteKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub target: RouteTarget, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC Router to which the route belongs. + pub vpc_router_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&RouterRoute> for RouterRoute { + fn from(value: &RouterRoute) -> Self { + value.clone() + } + } + + impl RouterRoute { + pub fn builder() -> builder::RouterRoute { + Default::default() + } + } + + ///Create-time parameters for a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "name", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RouterRouteCreateParams { + pub description: ::std::string::String, + pub destination: RouteDestination, + pub name: Name, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteCreateParams> for RouterRouteCreateParams { + fn from(value: &RouterRouteCreateParams) -> Self { + value.clone() + } + } + + impl RouterRouteCreateParams { + pub fn builder() -> builder::RouterRouteCreateParams { + Default::default() + } + } + + ///The classification of a [`RouterRoute`] as defined by the system. The + /// kind determines certain attributes such as if the route is modifiable + /// and describes how or where the route was created. + /// + ///See [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The classification of a [`RouterRoute`] as defined by the system. The kind determines certain attributes such as if the route is modifiable and describes how or where the route was created.\n\nSee [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context", + /// "oneOf": [ + /// { + /// "description": "Determines the default destination of traffic, such + /// as whether it goes to the internet or not.\n\n`Destination: An Internet + /// Gateway` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// }, + /// { + /// "description": "Automatically added for each VPC Subnet in the + /// VPC\n\n`Destination: A VPC Subnet` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_subnet" + /// ] + /// }, + /// { + /// "description": "Automatically added when VPC peering is + /// established\n\n`Destination: A different VPC` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_peering" + /// ] + /// }, + /// { + /// "description": "Created by a user See + /// [`RouteTarget`]\n\n`Destination: User defined` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "custom" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` + #[serde(rename = "default")] + Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` + #[serde(rename = "vpc_subnet")] + VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` + #[serde(rename = "vpc_peering")] + VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for RouterRouteKind { + fn from(value: &RouterRouteKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for RouterRouteKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Default => f.write_str("default"), + Self::VpcSubnet => f.write_str("vpc_subnet"), + Self::VpcPeering => f.write_str("vpc_peering"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for RouterRouteKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "default" => Ok(Self::Default), + "vpc_subnet" => Ok(Self::VpcSubnet), + "vpc_peering" => Ok(Self::VpcPeering), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/RouterRoute" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RouterRouteResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RouterRouteResultsPage> for RouterRouteResultsPage { + fn from(value: &RouterRouteResultsPage) -> Self { + value.clone() + } + } + + impl RouterRouteResultsPage { + pub fn builder() -> builder::RouterRouteResultsPage { + Default::default() + } + } + + ///Updateable properties of a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "destination", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct RouterRouteUpdateParams { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub destination: RouteDestination, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteUpdateParams> for RouterRouteUpdateParams { + fn from(value: &RouterRouteUpdateParams) -> Self { + value.clone() + } + } + + impl RouterRouteUpdateParams { + pub fn builder() -> builder::RouterRouteUpdateParams { + Default::default() + } + } + + ///`Saga` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SagaState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Saga { + pub id: ::uuid::Uuid, + pub state: SagaState, + } + + impl ::std::convert::From<&Saga> for Saga { + fn from(value: &Saga) -> Self { + value.clone() + } + } + + impl Saga { + pub fn builder() -> builder::Saga { + Default::default() + } + } + + ///`SagaErrorInfo` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "source_error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "action_failed" + /// ] + /// }, + /// "source_error": {} + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "deserialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "injected_error" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "serialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "subsaga_create_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "error")] + pub enum SagaErrorInfo { + #[serde(rename = "action_failed")] + ActionFailed { source_error: ::serde_json::Value }, + #[serde(rename = "deserialize_failed")] + DeserializeFailed { message: ::std::string::String }, + #[serde(rename = "injected_error")] + InjectedError, + #[serde(rename = "serialize_failed")] + SerializeFailed { message: ::std::string::String }, + #[serde(rename = "subsaga_create_failed")] + SubsagaCreateFailed { message: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for SagaErrorInfo { + fn from(value: &SagaErrorInfo) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Saga" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SagaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SagaResultsPage> for SagaResultsPage { + fn from(value: &SagaResultsPage) -> Self { + value.clone() + } + } + + impl SagaResultsPage { + pub fn builder() -> builder::SagaResultsPage { + Default::default() + } + } + + ///`SagaState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "succeeded" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error_info", + /// "error_node_name", + /// "state" + /// ], + /// "properties": { + /// "error_info": { + /// "$ref": "#/components/schemas/SagaErrorInfo" + /// }, + /// "error_node_name": { + /// "$ref": "#/components/schemas/NodeName" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "state")] + pub enum SagaState { + #[serde(rename = "running")] + Running, + #[serde(rename = "succeeded")] + Succeeded, + #[serde(rename = "failed")] + Failed { + error_info: SagaErrorInfo, + error_node_name: NodeName, + }, + } + + impl ::std::convert::From<&Self> for SagaState { + fn from(value: &SagaState) -> Self { + value.clone() + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "id", + /// "idp_entity_id", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_cert": { + /// "description": "optional request signing public certificate (base64 + /// encoded der file)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SamlIdentityProvider { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///optional request signing public certificate (base64 encoded der + /// file) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub public_cert: ::std::option::Option<::std::string::String>, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SamlIdentityProvider> for SamlIdentityProvider { + fn from(value: &SamlIdentityProvider) -> Self { + value.clone() + } + } + + impl SamlIdentityProvider { + pub fn builder() -> builder::SamlIdentityProvider { + Default::default() + } + } + + ///Create-time identity-related parameters + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time identity-related parameters", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "idp_entity_id", + /// "idp_metadata_source", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "group_attribute_name": { + /// "description": "If set, SAML attributes with this name will be + /// considered to denote a user's group membership, where the attribute + /// value(s) should be a comma-separated list of group names.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "idp_metadata_source": { + /// "description": "the source of an identity provider metadata + /// descriptor", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdpMetadataSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "signing_keypair": { + /// "description": "optional request signing key pair", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DerEncodedKeyPair" + /// } + /// ] + /// } + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SamlIdentityProviderCreate { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + pub description: ::std::string::String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub group_attribute_name: ::std::option::Option<::std::string::String>, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///the source of an identity provider metadata descriptor + pub idp_metadata_source: IdpMetadataSource, + pub name: Name, + ///optional request signing key pair + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub signing_keypair: ::std::option::Option, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + } + + impl ::std::convert::From<&SamlIdentityProviderCreate> for SamlIdentityProviderCreate { + fn from(value: &SamlIdentityProviderCreate) -> Self { + value.clone() + } + } + + impl SamlIdentityProviderCreate { + pub fn builder() -> builder::SamlIdentityProviderCreate { + Default::default() + } + } + + ///`SemverVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "pattern": "^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct SemverVersion(::std::string::String); + impl ::std::ops::Deref for SemverVersion { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: SemverVersion) -> Self { + value.0 + } + } + + impl ::std::convert::From<&SemverVersion> for SemverVersion { + fn from(value: &SemverVersion) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for SemverVersion { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The service intended to use this certificate. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The service intended to use this certificate.", + /// "oneOf": [ + /// { + /// "description": "This certificate is intended for access to the + /// external API.", + /// "type": "string", + /// "enum": [ + /// "external_api" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ::std::convert::From<&Self> for ServiceUsingCertificate { + fn from(value: &ServiceUsingCertificate) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ServiceUsingCertificate { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::ExternalApi => f.write_str("external_api"), + } + } + } + + impl ::std::str::FromStr for ServiceUsingCertificate { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a ['Silo'] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a ['Silo']", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "id", + /// "identity_mode", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "discoverable": { + /// "description": "A silo where discoverable is false can be retrieved only by its id - it will not be part of the \"list all silos\" output.", + /// "type": "boolean" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_mode": { + /// "description": "How users and groups are managed in this Silo", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Silo { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///A silo where discoverable is false can be retrieved only by its id - + /// it will not be part of the "list all silos" output. + pub discoverable: bool, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Silo> for Silo { + fn from(value: &Silo) -> Self { + value.clone() + } + } + + impl Silo { + pub fn builder() -> builder::Silo { + Default::default() + } + } + + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Silo`](crate::external_api::views::Silo)", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "identity_mode", + /// "name" + /// ], + /// "properties": { + /// "admin_group_name": { + /// "description": "If set, this group will be created during Silo + /// creation and granted the \"Silo Admin\" role. Identity providers can + /// assert that users belong to this group and those users can log in and + /// further initialize the Silo.\n\nNote that if configuring a SAML based + /// identity provider, group_attribute_name must be set for users to be + /// considered part of a group. See [`SamlIdentityProviderCreate`] for more + /// information.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "discoverable": { + /// "type": "boolean" + /// }, + /// "identity_mode": { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub admin_group_name: ::std::option::Option<::std::string::String>, + pub description: ::std::string::String, + pub discoverable: bool, + pub identity_mode: SiloIdentityMode, + pub name: Name, + } + + impl ::std::convert::From<&SiloCreate> for SiloCreate { + fn from(value: &SiloCreate) -> Self { + value.clone() + } + } + + impl SiloCreate { + pub fn builder() -> builder::SiloCreate { + Default::default() + } + } + + ///Describes how identities are managed and users are authenticated in this + /// Silo + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes how identities are managed and users are + /// authenticated in this Silo", + /// "oneOf": [ + /// { + /// "description": "Users are authenticated with SAML using an external + /// authentication provider. The system updates information about users and + /// groups only during successful authentication (i.e,. \"JIT provisioning\" + /// of users and groups).", + /// "type": "string", + /// "enum": [ + /// "saml_jit" + /// ] + /// }, + /// { + /// "description": "The system is the source of truth about users. + /// There is no linkage to an external authentication provider or identity + /// provider.", + /// "type": "string", + /// "enum": [ + /// "local_only" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ::std::convert::From<&Self> for SiloIdentityMode { + fn from(value: &SiloIdentityMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloIdentityMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SamlJit => f.write_str("saml_jit"), + Self::LocalOnly => f.write_str("local_only"), + } + } + } + + impl ::std::str::FromStr for SiloIdentityMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Silo" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SiloResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SiloResultsPage> for SiloResultsPage { + fn from(value: &SiloResultsPage) -> Self { + value.clone() + } + } + + impl SiloResultsPage { + pub fn builder() -> builder::SiloResultsPage { + Default::default() + } + } + + ///`SiloRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum SiloRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for SiloRole { + fn from(value: &SiloRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for SiloRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SiloRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SiloRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&SiloRolePolicy> for SiloRolePolicy { + fn from(value: &SiloRolePolicy) -> Self { + value.clone() + } + } + + impl SiloRolePolicy { + pub fn builder() -> builder::SiloRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/SiloRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SiloRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: SiloRole, + } + + impl ::std::convert::From<&SiloRoleRoleAssignment> for SiloRoleRoleAssignment { + fn from(value: &SiloRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl SiloRoleRoleAssignment { + pub fn builder() -> builder::SiloRoleRoleAssignment { + Default::default() + } + } + + ///Client view of a [`Sled`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Sled`]", + /// "type": "object", + /// "required": [ + /// "baseboard", + /// "id", + /// "service_address", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "baseboard": { + /// "$ref": "#/components/schemas/Baseboard" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "service_address": { + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Sled { + pub baseboard: Baseboard, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub service_address: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Sled> for Sled { + fn from(value: &Sled) -> Self { + value.clone() + } + } + + impl Sled { + pub fn builder() -> builder::Sled { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Sled" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SledResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SledResultsPage> for SledResultsPage { + fn from(value: &SledResultsPage) -> Self { + value.clone() + } + } + + impl SledResultsPage { + pub fn builder() -> builder::SledResultsPage { + Default::default() + } + } + + ///Client view of a Snapshot + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a Snapshot", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_id", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SnapshotState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Snapshot { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub disk_id: ::uuid::Uuid, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + pub state: SnapshotState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Snapshot> for Snapshot { + fn from(value: &Snapshot) -> Self { + value.clone() + } + } + + impl Snapshot { + pub fn builder() -> builder::Snapshot { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk": { + /// "description": "The name of the disk to be snapshotted", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SnapshotCreate { + pub description: ::std::string::String, + ///The name of the disk to be snapshotted + pub disk: Name, + pub name: Name, + } + + impl ::std::convert::From<&SnapshotCreate> for SnapshotCreate { + fn from(value: &SnapshotCreate) -> Self { + value.clone() + } + } + + impl SnapshotCreate { + pub fn builder() -> builder::SnapshotCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Snapshot" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SnapshotResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SnapshotResultsPage> for SnapshotResultsPage { + fn from(value: &SnapshotResultsPage) -> Self { + value.clone() + } + } + + impl SnapshotResultsPage { + pub fn builder() -> builder::SnapshotResultsPage { + Default::default() + } + } + + ///`SnapshotState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "creating", + /// "ready", + /// "faulted", + /// "destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for SnapshotState { + fn from(value: &SnapshotState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SnapshotState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Ready => f.write_str("ready"), + Self::Faulted => f.write_str("faulted"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for SnapshotState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`SpoofLoginBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "username" + /// ], + /// "properties": { + /// "username": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SpoofLoginBody { + pub username: ::std::string::String, + } + + impl ::std::convert::From<&SpoofLoginBody> for SpoofLoginBody { + fn from(value: &SpoofLoginBody) -> Self { + value.clone() + } + } + + impl SpoofLoginBody { + pub fn builder() -> builder::SpoofLoginBody { + Default::default() + } + } + + ///Client view of a [`SshKey`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`SshKey`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "public_key", + /// "silo_user_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// }, + /// "silo_user_id": { + /// "description": "The user to whom this key belongs", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SshKey { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + ///The user to whom this key belongs + pub silo_user_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SshKey> for SshKey { + fn from(value: &SshKey) -> Self { + value.clone() + } + } + + impl SshKey { + pub fn builder() -> builder::SshKey { + Default::default() + } + } + + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "public_key" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SshKeyCreate { + pub description: ::std::string::String, + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + } + + impl ::std::convert::From<&SshKeyCreate> for SshKeyCreate { + fn from(value: &SshKeyCreate) -> Self { + value.clone() + } + } + + impl SshKeyCreate { + pub fn builder() -> builder::SshKeyCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SshKey" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SshKeyResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SshKeyResultsPage> for SshKeyResultsPage { + fn from(value: &SshKeyResultsPage) -> Self { + value.clone() + } + } + + impl SshKeyResultsPage { + pub fn builder() -> builder::SshKeyResultsPage { + Default::default() + } + } + + ///`SystemMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "virtual_disk_space_provisioned", + /// "cpus_provisioned", + /// "ram_provisioned" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ::std::convert::From<&Self> for SystemMetricName { + fn from(value: &SystemMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SystemMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::VirtualDiskSpaceProvisioned => f.write_str("virtual_disk_space_provisioned"), + Self::CpusProvisioned => f.write_str("cpus_provisioned"), + Self::RamProvisioned => f.write_str("ram_provisioned"), + } + } + } + + impl ::std::str::FromStr for SystemMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdate> for SystemUpdate { + fn from(value: &SystemUpdate) -> Self { + value.clone() + } + } + + impl SystemUpdate { + pub fn builder() -> builder::SystemUpdate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SystemUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SystemUpdateResultsPage> for SystemUpdateResultsPage { + fn from(value: &SystemUpdateResultsPage) -> Self { + value.clone() + } + } + + impl SystemUpdateResultsPage { + pub fn builder() -> builder::SystemUpdateResultsPage { + Default::default() + } + } + + ///`SystemUpdateStart` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "version" + /// ], + /// "properties": { + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdateStart> for SystemUpdateStart { + fn from(value: &SystemUpdateStart) -> Self { + value.clone() + } + } + + impl SystemUpdateStart { + pub fn builder() -> builder::SystemUpdateStart { + Default::default() + } + } + + ///`SystemVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "status", + /// "version_range" + /// ], + /// "properties": { + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "version_range": { + /// "$ref": "#/components/schemas/VersionRange" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + + impl ::std::convert::From<&SystemVersion> for SystemVersion { + fn from(value: &SystemVersion) -> Self { + value.clone() + } + } + + impl SystemVersion { + pub fn builder() -> builder::SystemVersion { + Default::default() + } + } + + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "The name of a timeseries", + /// "description": "Names are constructed by concatenating the target and + /// metric names with ':'. Target and metric names must be lowercase + /// alphanumeric characters with '_' separating words.", + /// "type": "string", + /// "pattern": + /// "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct TimeseriesName(::std::string::String); + impl ::std::ops::Deref for TimeseriesName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: TimeseriesName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&TimeseriesName> for TimeseriesName { + fn from(value: &TimeseriesName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for TimeseriesName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ + )(_([a-z0-9]+))*)\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for TimeseriesName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The schema for a timeseries. + /// + ///This includes the name of the timeseries, as well as the datum type of + /// its metric and the schema for each field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The schema for a timeseries.\n\nThis includes the name + /// of the timeseries, as well as the datum type of its metric and the + /// schema for each field.", + /// "type": "object", + /// "required": [ + /// "created", + /// "datum_type", + /// "field_schema", + /// "timeseries_name" + /// ], + /// "properties": { + /// "created": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "datum_type": { + /// "$ref": "#/components/schemas/DatumType" + /// }, + /// "field_schema": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FieldSchema" + /// } + /// }, + /// "timeseries_name": { + /// "$ref": "#/components/schemas/TimeseriesName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TimeseriesSchema { + pub created: ::chrono::DateTime<::chrono::offset::Utc>, + pub datum_type: DatumType, + pub field_schema: ::std::vec::Vec, + pub timeseries_name: TimeseriesName, + } + + impl ::std::convert::From<&TimeseriesSchema> for TimeseriesSchema { + fn from(value: &TimeseriesSchema) -> Self { + value.clone() + } + } + + impl TimeseriesSchema { + pub fn builder() -> builder::TimeseriesSchema { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/TimeseriesSchema" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct TimeseriesSchemaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&TimeseriesSchemaResultsPage> for TimeseriesSchemaResultsPage { + fn from(value: &TimeseriesSchemaResultsPage) -> Self { + value.clone() + } + } + + impl TimeseriesSchemaResultsPage { + pub fn builder() -> builder::TimeseriesSchemaResultsPage { + Default::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "status", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateDeployment> for UpdateDeployment { + fn from(value: &UpdateDeployment) -> Self { + value.clone() + } + } + + impl UpdateDeployment { + pub fn builder() -> builder::UpdateDeployment { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateDeployment" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateDeploymentResultsPage> for UpdateDeploymentResultsPage { + fn from(value: &UpdateDeploymentResultsPage) -> Self { + value.clone() + } + } + + impl UpdateDeploymentResultsPage { + pub fn builder() -> builder::UpdateDeploymentResultsPage { + Default::default() + } + } + + ///`UpdateStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "updating" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "steady" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ::std::convert::From<&Self> for UpdateStatus { + fn from(value: &UpdateStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Updating => f.write_str("updating"), + Self::Steady => f.write_str("steady"), + } + } + } + + impl ::std::str::FromStr for UpdateStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "device_id", + /// "id", + /// "status", + /// "system_version", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "device_id": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "system_version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateableComponent> for UpdateableComponent { + fn from(value: &UpdateableComponent) -> Self { + value.clone() + } + } + + impl UpdateableComponent { + pub fn builder() -> builder::UpdateableComponent { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateableComponent" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateableComponentResultsPage> for UpdateableComponentResultsPage { + fn from(value: &UpdateableComponentResultsPage) -> Self { + value.clone() + } + } + + impl UpdateableComponentResultsPage { + pub fn builder() -> builder::UpdateableComponentResultsPage { + Default::default() + } + } + + ///`UpdateableComponentType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "bootloader_for_rot", + /// "bootloader_for_sp", + /// "bootloader_for_host_proc", + /// "hubris_for_psc_rot", + /// "hubris_for_psc_sp", + /// "hubris_for_sidecar_rot", + /// "hubris_for_sidecar_sp", + /// "hubris_for_gimlet_rot", + /// "hubris_for_gimlet_sp", + /// "helios_host_phase1", + /// "helios_host_phase2", + /// "host_omicron" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ::std::convert::From<&Self> for UpdateableComponentType { + fn from(value: &UpdateableComponentType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateableComponentType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::BootloaderForRot => f.write_str("bootloader_for_rot"), + Self::BootloaderForSp => f.write_str("bootloader_for_sp"), + Self::BootloaderForHostProc => f.write_str("bootloader_for_host_proc"), + Self::HubrisForPscRot => f.write_str("hubris_for_psc_rot"), + Self::HubrisForPscSp => f.write_str("hubris_for_psc_sp"), + Self::HubrisForSidecarRot => f.write_str("hubris_for_sidecar_rot"), + Self::HubrisForSidecarSp => f.write_str("hubris_for_sidecar_sp"), + Self::HubrisForGimletRot => f.write_str("hubris_for_gimlet_rot"), + Self::HubrisForGimletSp => f.write_str("hubris_for_gimlet_sp"), + Self::HeliosHostPhase1 => f.write_str("helios_host_phase1"), + Self::HeliosHostPhase2 => f.write_str("helios_host_phase2"), + Self::HostOmicron => f.write_str("host_omicron"), + } + } + } + + impl ::std::str::FromStr for UpdateableComponentType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`User`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`User`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the user", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this user belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct User { + ///Human-readable name that can identify the user + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + impl User { + pub fn builder() -> builder::User { + Default::default() + } + } + + ///Client view of a [`UserBuiltin`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`UserBuiltin`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserBuiltin { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&UserBuiltin> for UserBuiltin { + fn from(value: &UserBuiltin) -> Self { + value.clone() + } + } + + impl UserBuiltin { + pub fn builder() -> builder::UserBuiltin { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UserBuiltin" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserBuiltinResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserBuiltinResultsPage> for UserBuiltinResultsPage { + fn from(value: &UserBuiltinResultsPage) -> Self { + value.clone() + } + } + + impl UserBuiltinResultsPage { + pub fn builder() -> builder::UserBuiltinResultsPage { + Default::default() + } + } + + ///Create-time parameters for a [`User`](crate::external_api::views::User) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`User`](crate::external_api::views::User)", + /// "type": "object", + /// "required": [ + /// "external_id", + /// "password" + /// ], + /// "properties": { + /// "external_id": { + /// "description": "username used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserId" + /// } + /// ] + /// }, + /// "password": { + /// "description": "password used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserPassword" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + Default::default() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct UserId(::std::string::String); + impl ::std::ops::Deref for UserId { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: UserId) -> Self { + value.0 + } + } + + impl ::std::convert::From<&UserId> for UserId { + fn from(value: &UserId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for UserId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for UserId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Parameters for setting a user's password + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for setting a user's password", + /// "oneOf": [ + /// { + /// "description": "Sets the user's password to the provided value", + /// "type": "object", + /// "required": [ + /// "details", + /// "user_password_value" + /// ], + /// "properties": { + /// "details": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "password" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Invalidates any current password (disabling + /// password authentication)", + /// "type": "object", + /// "required": [ + /// "user_password_value" + /// ], + /// "properties": { + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "invalid_password" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + + impl ::std::convert::From<&Self> for UserPassword { + fn from(value: &UserPassword) -> Self { + value.clone() + } + } + + impl ::std::convert::From for UserPassword { + fn from(value: Password) -> Self { + Self::Password(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/User" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UserResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserResultsPage> for UserResultsPage { + fn from(value: &UserResultsPage) -> Self { + value.clone() + } + } + + impl UserResultsPage { + pub fn builder() -> builder::UserResultsPage { + Default::default() + } + } + + ///Credentials for local user login + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Credentials for local user login", + /// "type": "object", + /// "required": [ + /// "password", + /// "username" + /// ], + /// "properties": { + /// "password": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "username": { + /// "$ref": "#/components/schemas/UserId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + impl ::std::convert::From<&UsernamePasswordCredentials> for UsernamePasswordCredentials { + fn from(value: &UsernamePasswordCredentials) -> Self { + value.clone() + } + } + + impl UsernamePasswordCredentials { + pub fn builder() -> builder::UsernamePasswordCredentials { + Default::default() + } + } + + ///`VersionRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "high", + /// "low" + /// ], + /// "properties": { + /// "high": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "low": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + + impl ::std::convert::From<&VersionRange> for VersionRange { + fn from(value: &VersionRange) -> Self { + value.clone() + } + } + + impl VersionRange { + pub fn builder() -> builder::VersionRange { + Default::default() + } + } + + ///Client view of a [`Vpc`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Vpc`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "id", + /// "ipv6_prefix", + /// "name", + /// "project_id", + /// "system_router_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "dns_name": { + /// "description": "The name used for the VPC in DNS.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv6_prefix": { + /// "description": "The unique local IPv6 address range for subnets in + /// this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this VPC", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "system_router_id": { + /// "description": "id for the system router where subnet default + /// routes are registered", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Vpc { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///The name used for the VPC in DNS. + pub dns_name: Name, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The unique local IPv6 address range for subnets in this VPC + pub ipv6_prefix: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///id for the project containing this VPC + pub project_id: ::uuid::Uuid, + ///id for the system router where subnet default routes are registered + pub system_router_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Vpc> for Vpc { + fn from(value: &Vpc) -> Self { + value.clone() + } + } + + impl Vpc { + pub fn builder() -> builder::Vpc { + Default::default() + } + } + + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "dns_name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ipv6_prefix": { + /// "description": "The IPv6 prefix for this VPC.\n\nAll IPv6 subnets + /// created from this VPC must be taken from this range, which sould be a + /// Unique Local Address in the range `fd00::/48`. The default VPC Subnet + /// will have the first `/64` range from this prefix.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcCreate { + pub description: ::std::string::String, + pub dns_name: Name, + ///The IPv6 prefix for this VPC. + /// + ///All IPv6 subnets created from this VPC must be taken from this + /// range, which sould be a Unique Local Address in the range + /// `fd00::/48`. The default VPC Subnet will have the first `/64` range + /// from this prefix. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_prefix: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcCreate> for VpcCreate { + fn from(value: &VpcCreate) -> Self { + value.clone() + } + } + + impl VpcCreate { + pub fn builder() -> builder::VpcCreate { + Default::default() + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "id", + /// "name", + /// "priority", + /// "status", + /// "targets", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "the VPC to which this rule belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcFirewallRule { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///the VPC to which this rule belongs + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcFirewallRule> for VpcFirewallRule { + fn from(value: &VpcFirewallRule) -> Self { + value.clone() + } + } + + impl VpcFirewallRule { + pub fn builder() -> builder::VpcFirewallRule { + Default::default() + } + } + + ///`VpcFirewallRuleAction` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "allow", + /// "deny" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum VpcFirewallRuleAction { + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleAction { + fn from(value: &VpcFirewallRuleAction) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleAction { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Allow => f.write_str("allow"), + Self::Deny => f.write_str("deny"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleAction { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "allow" => Ok(Self::Allow), + "deny" => Ok(Self::Deny), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleDirection` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "inbound", + /// "outbound" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum VpcFirewallRuleDirection { + #[serde(rename = "inbound")] + Inbound, + #[serde(rename = "outbound")] + Outbound, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleDirection { + fn from(value: &VpcFirewallRuleDirection) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleDirection { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Inbound => f.write_str("inbound"), + Self::Outbound => f.write_str("outbound"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleDirection { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "inbound" => Ok(Self::Inbound), + "outbound" => Ok(Self::Outbound), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Filter for a firewall rule. A given packet must match every field that + /// is present for the rule to apply to it. A packet matches a field if any + /// entry in that field matches the packet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Filter for a firewall rule. A given packet must match + /// every field that is present for the rule to apply to it. A packet + /// matches a field if any entry in that field matches the packet.", + /// "type": "object", + /// "properties": { + /// "hosts": { + /// "description": "If present, the sources (if incoming) or + /// destinations (if outgoing) this rule applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleHostFilter" + /// } + /// }, + /// "ports": { + /// "description": "If present, the destination ports this rule applies + /// to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/L4PortRange" + /// } + /// }, + /// "protocols": { + /// "description": "If present, the networking protocols this rule + /// applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleProtocol" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcFirewallRuleFilter { + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub hosts: ::std::option::Option<::std::vec::Vec>, + ///If present, the destination ports this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ports: ::std::option::Option<::std::vec::Vec>, + ///If present, the networking protocols this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub protocols: ::std::option::Option<::std::vec::Vec>, + } + + impl ::std::convert::From<&VpcFirewallRuleFilter> for VpcFirewallRuleFilter { + fn from(value: &VpcFirewallRuleFilter) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcFirewallRuleFilter { + fn default() -> Self { + Self { + hosts: Default::default(), + ports: Default::default(), + protocols: Default::default(), + } + } + } + + impl VpcFirewallRuleFilter { + pub fn builder() -> builder::VpcFirewallRuleFilter { + Default::default() + } + } + + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `VpcFirewallRuleHostFilter` is used to filter + /// traffic on the basis of its source or destination host.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to this specific + /// instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleHostFilter { + ///The rule applies to traffic from/to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to traffic from/to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to traffic from/to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to traffic from/to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to traffic from/to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleHostFilter { + fn from(value: &VpcFirewallRuleHostFilter) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleHostFilter { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleHostFilter { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///The protocols that may be specified in a firewall rule's filter + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The protocols that may be specified in a firewall + /// rule's filter", + /// "type": "string", + /// "enum": [ + /// "TCP", + /// "UDP", + /// "ICMP" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum VpcFirewallRuleProtocol { + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, + #[serde(rename = "ICMP")] + Icmp, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleProtocol { + fn from(value: &VpcFirewallRuleProtocol) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleProtocol { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Tcp => f.write_str("TCP"), + Self::Udp => f.write_str("UDP"), + Self::Icmp => f.write_str("ICMP"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleProtocol { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "TCP" => Ok(Self::Tcp), + "UDP" => Ok(Self::Udp), + "ICMP" => Ok(Self::Icmp), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "disabled", + /// "enabled" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum VpcFirewallRuleStatus { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleStatus { + fn from(value: &VpcFirewallRuleStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Disabled => f.write_str("disabled"), + Self::Enabled => f.write_str("enabled"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "disabled" => Ok(Self::Disabled), + "enabled" => Ok(Self::Enabled), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `VpcFirewallRuleTarget` is used to specify the set of + /// [`Instance`]s to which a firewall rule applies.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to all instances in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to all instances in the VPC + /// Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to this specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleTarget { + ///The rule applies to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleTarget { + fn from(value: &VpcFirewallRuleTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleTarget { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "name", + /// "priority", + /// "status", + /// "targets" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "name": { + /// "description": "name of the rule, unique to this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcFirewallRuleUpdate { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///name of the rule, unique to this VPC + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdate> for VpcFirewallRuleUpdate { + fn from(value: &VpcFirewallRuleUpdate) -> Self { + value.clone() + } + } + + impl VpcFirewallRuleUpdate { + pub fn builder() -> builder::VpcFirewallRuleUpdate { + Default::default() + } + } + + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a `Vpc`'s firewall Note that + /// VpcFirewallRules are implicitly created along with a Vpc, so there is no + /// explicit creation.", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleUpdate" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcFirewallRuleUpdateParams { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdateParams> for VpcFirewallRuleUpdateParams { + fn from(value: &VpcFirewallRuleUpdateParams) -> Self { + value.clone() + } + } + + impl VpcFirewallRuleUpdateParams { + pub fn builder() -> builder::VpcFirewallRuleUpdateParams { + Default::default() + } + } + + ///Collection of a Vpc's firewall rules + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Collection of a Vpc's firewall rules", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRule" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcFirewallRules { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRules> for VpcFirewallRules { + fn from(value: &VpcFirewallRules) -> Self { + value.clone() + } + } + + impl VpcFirewallRules { + pub fn builder() -> builder::VpcFirewallRules { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Vpc" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcResultsPage> for VpcResultsPage { + fn from(value: &VpcResultsPage) -> Self { + value.clone() + } + } + + impl VpcResultsPage { + pub fn builder() -> builder::VpcResultsPage { + Default::default() + } + } + + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC router defines a series of rules that indicate + /// where traffic should be sent depending on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "kind", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/VpcRouterKind" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the router belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcRouter { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub kind: VpcRouterKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the router belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcRouter> for VpcRouter { + fn from(value: &VpcRouter) -> Self { + value.clone() + } + } + + impl VpcRouter { + pub fn builder() -> builder::VpcRouter { + Default::default() + } + } + + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcRouterCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&VpcRouterCreate> for VpcRouterCreate { + fn from(value: &VpcRouterCreate) -> Self { + value.clone() + } + } + + impl VpcRouterCreate { + pub fn builder() -> builder::VpcRouterCreate { + Default::default() + } + } + + ///`VpcRouterKind` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "system", + /// "custom" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum VpcRouterKind { + #[serde(rename = "system")] + System, + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for VpcRouterKind { + fn from(value: &VpcRouterKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcRouterKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::System => f.write_str("system"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for VpcRouterKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "system" => Ok(Self::System), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcRouter" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcRouterResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcRouterResultsPage> for VpcRouterResultsPage { + fn from(value: &VpcRouterResultsPage) -> Self { + value.clone() + } + } + + impl VpcRouterResultsPage { + pub fn builder() -> builder::VpcRouterResultsPage { + Default::default() + } + } + + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcRouterUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcRouterUpdate> for VpcRouterUpdate { + fn from(value: &VpcRouterUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcRouterUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl VpcRouterUpdate { + pub fn builder() -> builder::VpcRouterUpdate { + Default::default() + } + } + + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC subnet represents a logical grouping for + /// instances that allows network traffic between them, within a IPv4 + /// subnetwork or optionall an IPv6 subnetwork.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "ipv4_block", + /// "ipv6_block", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the subnet belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcSubnet { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The IPv4 subnet CIDR block. + pub ipv4_block: Ipv4Net, + ///The IPv6 subnet CIDR block. + pub ipv6_block: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the subnet belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcSubnet> for VpcSubnet { + fn from(value: &VpcSubnet) -> Self { + value.clone() + } + } + + impl VpcSubnet { + pub fn builder() -> builder::VpcSubnet { + Default::default() + } + } + + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "required": [ + /// "description", + /// "ipv4_block", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 address range for this subnet.\n\nIt must + /// be allocated from an RFC 1918 private address range, and must not + /// overlap with any other existing subnet in the VPC.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 address range for this subnet.\n\nIt must + /// be allocated from the RFC 4193 Unique Local Address range, with the + /// prefix equal to the parent VPC's prefix. A random `/64` block will be + /// assigned if one is not provided. It must not overlap with any existing + /// subnet in the VPC.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcSubnetCreate { + pub description: ::std::string::String, + ///The IPv4 address range for this subnet. + /// + ///It must be allocated from an RFC 1918 private address range, and + /// must not overlap with any other existing subnet in the VPC. + pub ipv4_block: Ipv4Net, + ///The IPv6 address range for this subnet. + /// + ///It must be allocated from the RFC 4193 Unique Local Address range, + /// with the prefix equal to the parent VPC's prefix. A random `/64` + /// block will be assigned if one is not provided. It must not overlap + /// with any existing subnet in the VPC. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_block: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcSubnetCreate> for VpcSubnetCreate { + fn from(value: &VpcSubnetCreate) -> Self { + value.clone() + } + } + + impl VpcSubnetCreate { + pub fn builder() -> builder::VpcSubnetCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcSubnet" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcSubnetResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcSubnetResultsPage> for VpcSubnetResultsPage { + fn from(value: &VpcSubnetResultsPage) -> Self { + value.clone() + } + } + + impl VpcSubnetResultsPage { + pub fn builder() -> builder::VpcSubnetResultsPage { + Default::default() + } + } + + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcSubnetUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcSubnetUpdate> for VpcSubnetUpdate { + fn from(value: &VpcSubnetUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcSubnetUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl VpcSubnetUpdate { + pub fn builder() -> builder::VpcSubnetUpdate { + Default::default() + } + } + + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "dns_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct VpcUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub dns_name: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcUpdate> for VpcUpdate { + fn from(value: &VpcUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcUpdate { + fn default() -> Self { + Self { + description: Default::default(), + dns_name: Default::default(), + name: Default::default(), + } + } + } + + impl VpcUpdate { + pub fn builder() -> builder::VpcUpdate { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct Baseboard { + part: ::std::result::Result<::std::string::String, ::std::string::String>, + revision: ::std::result::Result, + serial: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Baseboard { + fn default() -> Self { + Self { + part: Err("no value supplied for part".to_string()), + revision: Err("no value supplied for revision".to_string()), + serial: Err("no value supplied for serial".to_string()), + } + } + } + + impl Baseboard { + pub fn part(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.part = value + .try_into() + .map_err(|e| format!("error converting supplied value for part: {}", e)); + self + } + pub fn revision(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.revision = value + .try_into() + .map_err(|e| format!("error converting supplied value for revision: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Baseboard { + type Error = super::error::ConversionError; + fn try_from( + value: Baseboard, + ) -> ::std::result::Result { + Ok(Self { + part: value.part?, + revision: value.revision?, + serial: value.serial?, + }) + } + } + + impl ::std::convert::From for Baseboard { + fn from(value: super::Baseboard) -> Self { + Self { + part: Ok(value.part), + revision: Ok(value.revision), + serial: Ok(value.serial), + } + } + } + + #[derive(Clone, Debug)] + pub struct Bindouble { + count: ::std::result::Result, + range: ::std::result::Result, + } + + impl ::std::default::Default for Bindouble { + fn default() -> Self { + Self { + count: Err("no value supplied for count".to_string()), + range: Err("no value supplied for range".to_string()), + } + } + } + + impl Bindouble { + pub fn count(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Bindouble { + type Error = super::error::ConversionError; + fn try_from( + value: Bindouble, + ) -> ::std::result::Result { + Ok(Self { + count: value.count?, + range: value.range?, + }) + } + } + + impl ::std::convert::From for Bindouble { + fn from(value: super::Bindouble) -> Self { + Self { + count: Ok(value.count), + range: Ok(value.range), + } + } + } + + #[derive(Clone, Debug)] + pub struct Binint64 { + count: ::std::result::Result, + range: ::std::result::Result, + } + + impl ::std::default::Default for Binint64 { + fn default() -> Self { + Self { + count: Err("no value supplied for count".to_string()), + range: Err("no value supplied for range".to_string()), + } + } + } + + impl Binint64 { + pub fn count(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Binint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Binint64, + ) -> ::std::result::Result { + Ok(Self { + count: value.count?, + range: value.range?, + }) + } + } + + impl ::std::convert::From for Binint64 { + fn from(value: super::Binint64) -> Self { + Self { + count: Ok(value.count), + range: Ok(value.range), + } + } + } + + #[derive(Clone, Debug)] + pub struct Certificate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + service: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Certificate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Certificate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Certificate { + type Error = super::error::ConversionError; + fn try_from( + value: Certificate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + service: value.service?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Certificate { + fn from(value: super::Certificate) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + service: Ok(value.service), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct CertificateCreate { + cert: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + key: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + name: ::std::result::Result, + service: ::std::result::Result, + } + + impl ::std::default::Default for CertificateCreate { + fn default() -> Self { + Self { + cert: Err("no value supplied for cert".to_string()), + description: Err("no value supplied for description".to_string()), + key: Err("no value supplied for key".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + } + } + } + + impl CertificateCreate { + pub fn cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CertificateCreate { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateCreate, + ) -> ::std::result::Result { + Ok(Self { + cert: value.cert?, + description: value.description?, + key: value.key?, + name: value.name?, + service: value.service?, + }) + } + } + + impl ::std::convert::From for CertificateCreate { + fn from(value: super::CertificateCreate) -> Self { + Self { + cert: Ok(value.cert), + description: Ok(value.description), + key: Ok(value.key), + name: Ok(value.name), + service: Ok(value.service), + } + } + } + + #[derive(Clone, Debug)] + pub struct CertificateResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for CertificateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl CertificateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CertificateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for CertificateResultsPage { + fn from(value: super::CertificateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct ComponentUpdate { + component_type: + ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for ComponentUpdate { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl ComponentUpdate { + pub fn component_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ComponentUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdate, + ) -> ::std::result::Result { + Ok(Self { + component_type: value.component_type?, + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for ComponentUpdate { + fn from(value: super::ComponentUpdate) -> Self { + Self { + component_type: Ok(value.component_type), + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct ComponentUpdateResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ComponentUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ComponentUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ComponentUpdateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ComponentUpdateResultsPage { + fn from(value: super::ComponentUpdateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Cumulativedouble { + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + value: ::std::result::Result, + } + + impl ::std::default::Default for Cumulativedouble { + fn default() -> Self { + Self { + start_time: Err("no value supplied for start_time".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl Cumulativedouble { + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Cumulativedouble { + type Error = super::error::ConversionError; + fn try_from( + value: Cumulativedouble, + ) -> ::std::result::Result { + Ok(Self { + start_time: value.start_time?, + value: value.value?, + }) + } + } + + impl ::std::convert::From for Cumulativedouble { + fn from(value: super::Cumulativedouble) -> Self { + Self { + start_time: Ok(value.start_time), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct Cumulativeint64 { + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + value: ::std::result::Result, + } + + impl ::std::default::Default for Cumulativeint64 { + fn default() -> Self { + Self { + start_time: Err("no value supplied for start_time".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl Cumulativeint64 { + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Cumulativeint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Cumulativeint64, + ) -> ::std::result::Result { + Ok(Self { + start_time: value.start_time?, + value: value.value?, + }) + } + } + + impl ::std::convert::From for Cumulativeint64 { + fn from(value: super::Cumulativeint64) -> Self { + Self { + start_time: Ok(value.start_time), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct DerEncodedKeyPair { + private_key: ::std::result::Result<::std::string::String, ::std::string::String>, + public_cert: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DerEncodedKeyPair { + fn default() -> Self { + Self { + private_key: Err("no value supplied for private_key".to_string()), + public_cert: Err("no value supplied for public_cert".to_string()), + } + } + } + + impl DerEncodedKeyPair { + pub fn private_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.private_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for private_key: {}", e)); + self + } + pub fn public_cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_cert: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DerEncodedKeyPair { + type Error = super::error::ConversionError; + fn try_from( + value: DerEncodedKeyPair, + ) -> ::std::result::Result { + Ok(Self { + private_key: value.private_key?, + public_cert: value.public_cert?, + }) + } + } + + impl ::std::convert::From for DerEncodedKeyPair { + fn from(value: super::DerEncodedKeyPair) -> Self { + Self { + private_key: Ok(value.private_key), + public_cert: Ok(value.public_cert), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAccessTokenRequest { + client_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + device_code: ::std::result::Result<::std::string::String, ::std::string::String>, + grant_type: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAccessTokenRequest { + fn default() -> Self { + Self { + client_id: Err("no value supplied for client_id".to_string()), + device_code: Err("no value supplied for device_code".to_string()), + grant_type: Err("no value supplied for grant_type".to_string()), + } + } + } + + impl DeviceAccessTokenRequest { + pub fn client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.client_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for client_id: {}", e)); + self + } + pub fn device_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_code: {}", e)); + self + } + pub fn grant_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.grant_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for grant_type: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAccessTokenRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAccessTokenRequest, + ) -> ::std::result::Result { + Ok(Self { + client_id: value.client_id?, + device_code: value.device_code?, + grant_type: value.grant_type?, + }) + } + } + + impl ::std::convert::From for DeviceAccessTokenRequest { + fn from(value: super::DeviceAccessTokenRequest) -> Self { + Self { + client_id: Ok(value.client_id), + device_code: Ok(value.device_code), + grant_type: Ok(value.grant_type), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAuthRequest { + client_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAuthRequest { + fn default() -> Self { + Self { + client_id: Err("no value supplied for client_id".to_string()), + } + } + } + + impl DeviceAuthRequest { + pub fn client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.client_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for client_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAuthRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAuthRequest, + ) -> ::std::result::Result { + Ok(Self { + client_id: value.client_id?, + }) + } + } + + impl ::std::convert::From for DeviceAuthRequest { + fn from(value: super::DeviceAuthRequest) -> Self { + Self { + client_id: Ok(value.client_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAuthVerify { + user_code: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAuthVerify { + fn default() -> Self { + Self { + user_code: Err("no value supplied for user_code".to_string()), + } + } + } + + impl DeviceAuthVerify { + pub fn user_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.user_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for user_code: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAuthVerify { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAuthVerify, + ) -> ::std::result::Result { + Ok(Self { + user_code: value.user_code?, + }) + } + } + + impl ::std::convert::From for DeviceAuthVerify { + fn from(value: super::DeviceAuthVerify) -> Self { + Self { + user_code: Ok(value.user_code), + } + } + } + + #[derive(Clone, Debug)] + pub struct Disk { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + device_path: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + image_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + snapshot_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Disk { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + device_path: Err("no value supplied for device_path".to_string()), + id: Err("no value supplied for id".to_string()), + image_id: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + snapshot_id: Ok(Default::default()), + state: Err("no value supplied for state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Disk { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn device_path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_path = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_path: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn image_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.image_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for image_id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn snapshot_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.snapshot_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for snapshot_id: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Disk { + type Error = super::error::ConversionError; + fn try_from(value: Disk) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + device_path: value.device_path?, + id: value.id?, + image_id: value.image_id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + snapshot_id: value.snapshot_id?, + state: value.state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Disk { + fn from(value: super::Disk) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + device_path: Ok(value.device_path), + id: Ok(value.id), + image_id: Ok(value.image_id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + snapshot_id: Ok(value.snapshot_id), + state: Ok(value.state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk_source: ::std::result::Result, + name: ::std::result::Result, + size: ::std::result::Result, + } + + impl ::std::default::Default for DiskCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk_source: Err("no value supplied for disk_source".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl DiskCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk_source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk_source = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_source: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskCreate { + type Error = super::error::ConversionError; + fn try_from( + value: DiskCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk_source: value.disk_source?, + name: value.name?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for DiskCreate { + fn from(value: super::DiskCreate) -> Self { + Self { + description: Ok(value.description), + disk_source: Ok(value.disk_source), + name: Ok(value.name), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskIdentifier { + name: ::std::result::Result, + } + + impl ::std::default::Default for DiskIdentifier { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl DiskIdentifier { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskIdentifier { + type Error = super::error::ConversionError; + fn try_from( + value: DiskIdentifier, + ) -> ::std::result::Result { + Ok(Self { name: value.name? }) + } + } + + impl ::std::convert::From for DiskIdentifier { + fn from(value: super::DiskIdentifier) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskPath { + disk: ::std::result::Result, + } + + impl ::std::default::Default for DiskPath { + fn default() -> Self { + Self { + disk: Err("no value supplied for disk".to_string()), + } + } + } + + impl DiskPath { + pub fn disk(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskPath { + type Error = super::error::ConversionError; + fn try_from( + value: DiskPath, + ) -> ::std::result::Result { + Ok(Self { disk: value.disk? }) + } + } + + impl ::std::convert::From for DiskPath { + fn from(value: super::DiskPath) -> Self { + Self { + disk: Ok(value.disk), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for DiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl DiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: DiskResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for DiskResultsPage { + fn from(value: super::DiskResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Distribution { + name: ::std::result::Result, + version: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Distribution { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl Distribution { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Distribution { + type Error = super::error::ConversionError; + fn try_from( + value: Distribution, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for Distribution { + fn from(value: super::Distribution) -> Self { + Self { + name: Ok(value.name), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + message: ::std::result::Result<::std::string::String, ::std::string::String>, + request_id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Error { + type Error = super::error::ConversionError; + fn try_from( + value: Error, + ) -> ::std::result::Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl ::std::convert::From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct ExternalIp { + ip: ::std::result::Result<::std::net::IpAddr, ::std::string::String>, + kind: ::std::result::Result, + } + + impl ::std::default::Default for ExternalIp { + fn default() -> Self { + Self { + ip: Err("no value supplied for ip".to_string()), + kind: Err("no value supplied for kind".to_string()), + } + } + } + + impl ExternalIp { + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::IpAddr>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ExternalIp { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIp, + ) -> ::std::result::Result { + Ok(Self { + ip: value.ip?, + kind: value.kind?, + }) + } + } + + impl ::std::convert::From for ExternalIp { + fn from(value: super::ExternalIp) -> Self { + Self { + ip: Ok(value.ip), + kind: Ok(value.kind), + } + } + } + + #[derive(Clone, Debug)] + pub struct ExternalIpResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ExternalIpResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ExternalIpResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ExternalIpResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIpResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ExternalIpResultsPage { + fn from(value: super::ExternalIpResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct FieldSchema { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + source: ::std::result::Result, + ty: ::std::result::Result, + } + + impl ::std::default::Default for FieldSchema { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + ty: Err("no value supplied for ty".to_string()), + } + } + } + + impl FieldSchema { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + pub fn ty(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ty = value + .try_into() + .map_err(|e| format!("error converting supplied value for ty: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::FieldSchema { + type Error = super::error::ConversionError; + fn try_from( + value: FieldSchema, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + source: value.source?, + ty: value.ty?, + }) + } + } + + impl ::std::convert::From for FieldSchema { + fn from(value: super::FieldSchema) -> Self { + Self { + name: Ok(value.name), + source: Ok(value.source), + ty: Ok(value.ty), + } + } + } + + #[derive(Clone, Debug)] + pub struct FleetRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for FleetRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl FleetRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::FleetRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for FleetRolePolicy { + fn from(value: super::FleetRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct FleetRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for FleetRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl FleetRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::FleetRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for FleetRoleRoleAssignment { + fn from(value: super::FleetRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImage { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + digest: + ::std::result::Result<::std::option::Option, ::std::string::String>, + distribution: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + size: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + url: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + version: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for GlobalImage { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + digest: Ok(Default::default()), + distribution: Err("no value supplied for distribution".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + url: Ok(Default::default()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl GlobalImage { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn digest(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.digest = value + .try_into() + .map_err(|e| format!("error converting supplied value for digest: {}", e)); + self + } + pub fn distribution(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.distribution = value.try_into().map_err(|e| { + format!("error converting supplied value for distribution: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImage { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImage, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + digest: value.digest?, + distribution: value.distribution?, + id: value.id?, + name: value.name?, + size: value.size?, + time_created: value.time_created?, + time_modified: value.time_modified?, + url: value.url?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for GlobalImage { + fn from(value: super::GlobalImage) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + digest: Ok(value.digest), + distribution: Ok(value.distribution), + id: Ok(value.id), + name: Ok(value.name), + size: Ok(value.size), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + url: Ok(value.url), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImageCreate { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + distribution: ::std::result::Result, + name: ::std::result::Result, + source: ::std::result::Result, + } + + impl ::std::default::Default for GlobalImageCreate { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + distribution: Err("no value supplied for distribution".to_string()), + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + } + } + } + + impl GlobalImageCreate { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn distribution(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.distribution = value.try_into().map_err(|e| { + format!("error converting supplied value for distribution: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImageCreate { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageCreate, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + distribution: value.distribution?, + name: value.name?, + source: value.source?, + }) + } + } + + impl ::std::convert::From for GlobalImageCreate { + fn from(value: super::GlobalImageCreate) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + distribution: Ok(value.distribution), + name: Ok(value.name), + source: Ok(value.source), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImageResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for GlobalImageResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GlobalImageResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImageResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for GlobalImageResultsPage { + fn from(value: super::GlobalImageResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Group { + display_name: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + silo_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for Group { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl Group { + pub fn display_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Group { + type Error = super::error::ConversionError; + fn try_from( + value: Group, + ) -> ::std::result::Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + impl ::std::convert::From for Group { + fn from(value: super::Group) -> Self { + Self { + display_name: Ok(value.display_name), + id: Ok(value.id), + silo_id: Ok(value.silo_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct GroupResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for GroupResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GroupResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GroupResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: GroupResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for GroupResultsPage { + fn from(value: super::GroupResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Histogramdouble { + bins: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + n_samples: ::std::result::Result, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Histogramdouble { + fn default() -> Self { + Self { + bins: Err("no value supplied for bins".to_string()), + n_samples: Err("no value supplied for n_samples".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl Histogramdouble { + pub fn bins(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.bins = value + .try_into() + .map_err(|e| format!("error converting supplied value for bins: {}", e)); + self + } + pub fn n_samples(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.n_samples = value + .try_into() + .map_err(|e| format!("error converting supplied value for n_samples: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Histogramdouble { + type Error = super::error::ConversionError; + fn try_from( + value: Histogramdouble, + ) -> ::std::result::Result { + Ok(Self { + bins: value.bins?, + n_samples: value.n_samples?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for Histogramdouble { + fn from(value: super::Histogramdouble) -> Self { + Self { + bins: Ok(value.bins), + n_samples: Ok(value.n_samples), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct Histogramint64 { + bins: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + n_samples: ::std::result::Result, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Histogramint64 { + fn default() -> Self { + Self { + bins: Err("no value supplied for bins".to_string()), + n_samples: Err("no value supplied for n_samples".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl Histogramint64 { + pub fn bins(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.bins = value + .try_into() + .map_err(|e| format!("error converting supplied value for bins: {}", e)); + self + } + pub fn n_samples(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.n_samples = value + .try_into() + .map_err(|e| format!("error converting supplied value for n_samples: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Histogramint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Histogramint64, + ) -> ::std::result::Result { + Ok(Self { + bins: value.bins?, + n_samples: value.n_samples?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for Histogramint64 { + fn from(value: super::Histogramint64) -> Self { + Self { + bins: Ok(value.bins), + n_samples: Ok(value.n_samples), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct IdentityProvider { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + provider_type: + ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IdentityProvider { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + provider_type: Err("no value supplied for provider_type".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl IdentityProvider { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn provider_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.provider_type = value.try_into().map_err(|e| { + format!("error converting supplied value for provider_type: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IdentityProvider { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProvider, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + provider_type: value.provider_type?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for IdentityProvider { + fn from(value: super::IdentityProvider) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + provider_type: Ok(value.provider_type), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct IdentityProviderResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IdentityProviderResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IdentityProviderResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IdentityProviderResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProviderResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IdentityProviderResultsPage { + fn from(value: super::IdentityProviderResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Image { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + digest: + ::std::result::Result<::std::option::Option, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + url: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + version: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Image { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + digest: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + url: Ok(Default::default()), + version: Ok(Default::default()), + } + } + } + + impl Image { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn digest(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.digest = value + .try_into() + .map_err(|e| format!("error converting supplied value for digest: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Image { + type Error = super::error::ConversionError; + fn try_from( + value: Image, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + digest: value.digest?, + id: value.id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + time_created: value.time_created?, + time_modified: value.time_modified?, + url: value.url?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for Image { + fn from(value: super::Image) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + digest: Ok(value.digest), + id: Ok(value.id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + url: Ok(value.url), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct ImageCreate { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + source: ::std::result::Result, + } + + impl ::std::default::Default for ImageCreate { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + } + } + } + + impl ImageCreate { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ImageCreate { + type Error = super::error::ConversionError; + fn try_from( + value: ImageCreate, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + name: value.name?, + source: value.source?, + }) + } + } + + impl ::std::convert::From for ImageCreate { + fn from(value: super::ImageCreate) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + name: Ok(value.name), + source: Ok(value.source), + } + } + } + + #[derive(Clone, Debug)] + pub struct ImageResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ImageResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ImageResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ImageResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ImageResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ImageResultsPage { + fn from(value: super::ImageResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Instance { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + hostname: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result, + ncpus: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + run_state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_run_state_updated: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Instance { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + hostname: Err("no value supplied for hostname".to_string()), + id: Err("no value supplied for id".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + ncpus: Err("no value supplied for ncpus".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + run_state: Err("no value supplied for run_state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + time_run_state_updated: Err( + "no value supplied for time_run_state_updated".to_string() + ), + } + } + } + + impl Instance { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn hostname(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.hostname = value + .try_into() + .map_err(|e| format!("error converting supplied value for hostname: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn ncpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ncpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for ncpus: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn run_state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.run_state = value + .try_into() + .map_err(|e| format!("error converting supplied value for run_state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn time_run_state_updated(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_run_state_updated = value.try_into().map_err(|e| { + format!( + "error converting supplied value for time_run_state_updated: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Instance { + type Error = super::error::ConversionError; + fn try_from( + value: Instance, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + hostname: value.hostname?, + id: value.id?, + memory: value.memory?, + name: value.name?, + ncpus: value.ncpus?, + project_id: value.project_id?, + run_state: value.run_state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + time_run_state_updated: value.time_run_state_updated?, + }) + } + } + + impl ::std::convert::From for Instance { + fn from(value: super::Instance) -> Self { + Self { + description: Ok(value.description), + hostname: Ok(value.hostname), + id: Ok(value.id), + memory: Ok(value.memory), + name: Ok(value.name), + ncpus: Ok(value.ncpus), + project_id: Ok(value.project_id), + run_state: Ok(value.run_state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + time_run_state_updated: Ok(value.time_run_state_updated), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disks: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + external_ips: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + hostname: ::std::result::Result<::std::string::String, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result, + ncpus: ::std::result::Result, + network_interfaces: ::std::result::Result< + super::InstanceNetworkInterfaceAttachment, + ::std::string::String, + >, + start: ::std::result::Result, + user_data: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for InstanceCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disks: Ok(Default::default()), + external_ips: Ok(Default::default()), + hostname: Err("no value supplied for hostname".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + ncpus: Err("no value supplied for ncpus".to_string()), + network_interfaces: Ok(super::defaults::instance_create_network_interfaces()), + start: Ok(super::defaults::default_bool::()), + user_data: Ok(Default::default()), + } + } + } + + impl InstanceCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn external_ips(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.external_ips = value.try_into().map_err(|e| { + format!("error converting supplied value for external_ips: {}", e) + }); + self + } + pub fn hostname(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.hostname = value + .try_into() + .map_err(|e| format!("error converting supplied value for hostname: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn ncpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ncpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for ncpus: {}", e)); + self + } + pub fn network_interfaces(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.network_interfaces = value.try_into().map_err(|e| { + format!( + "error converting supplied value for network_interfaces: {}", + e + ) + }); + self + } + pub fn start(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.start = value + .try_into() + .map_err(|e| format!("error converting supplied value for start: {}", e)); + self + } + pub fn user_data(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.user_data = value + .try_into() + .map_err(|e| format!("error converting supplied value for user_data: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceCreate { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disks: value.disks?, + external_ips: value.external_ips?, + hostname: value.hostname?, + memory: value.memory?, + name: value.name?, + ncpus: value.ncpus?, + network_interfaces: value.network_interfaces?, + start: value.start?, + user_data: value.user_data?, + }) + } + } + + impl ::std::convert::From for InstanceCreate { + fn from(value: super::InstanceCreate) -> Self { + Self { + description: Ok(value.description), + disks: Ok(value.disks), + external_ips: Ok(value.external_ips), + hostname: Ok(value.hostname), + memory: Ok(value.memory), + name: Ok(value.name), + ncpus: Ok(value.ncpus), + network_interfaces: Ok(value.network_interfaces), + start: Ok(value.start), + user_data: Ok(value.user_data), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrate { + dst_sled_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrate { + fn default() -> Self { + Self { + dst_sled_id: Err("no value supplied for dst_sled_id".to_string()), + } + } + } + + impl InstanceMigrate { + pub fn dst_sled_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.dst_sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for dst_sled_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceMigrate { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrate, + ) -> ::std::result::Result { + Ok(Self { + dst_sled_id: value.dst_sled_id?, + }) + } + } + + impl ::std::convert::From for InstanceMigrate { + fn from(value: super::InstanceMigrate) -> Self { + Self { + dst_sled_id: Ok(value.dst_sled_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for InstanceResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl InstanceResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for InstanceResultsPage { + fn from(value: super::InstanceResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceSerialConsoleData { + data: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + last_byte_offset: ::std::result::Result, + } + + impl ::std::default::Default for InstanceSerialConsoleData { + fn default() -> Self { + Self { + data: Err("no value supplied for data".to_string()), + last_byte_offset: Err("no value supplied for last_byte_offset".to_string()), + } + } + } + + impl InstanceSerialConsoleData { + pub fn data(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.data = value + .try_into() + .map_err(|e| format!("error converting supplied value for data: {}", e)); + self + } + pub fn last_byte_offset(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.last_byte_offset = value.try_into().map_err(|e| { + format!( + "error converting supplied value for last_byte_offset: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceSerialConsoleData { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceSerialConsoleData, + ) -> ::std::result::Result { + Ok(Self { + data: value.data?, + last_byte_offset: value.last_byte_offset?, + }) + } + } + + impl ::std::convert::From for InstanceSerialConsoleData { + fn from(value: super::InstanceSerialConsoleData) -> Self { + Self { + data: Ok(value.data), + last_byte_offset: Ok(value.last_byte_offset), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPool { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPool { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl IpPool { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IpPool { + type Error = super::error::ConversionError; + fn try_from( + value: IpPool, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for IpPool { + fn from(value: super::IpPool) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for IpPoolCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl IpPoolCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolCreate { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for IpPoolCreate { + fn from(value: super::IpPoolCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolRange { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + range: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolRange { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + range: Err("no value supplied for range".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + } + } + } + + impl IpPoolRange { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolRange { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRange, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + range: value.range?, + time_created: value.time_created?, + }) + } + } + + impl ::std::convert::From for IpPoolRange { + fn from(value: super::IpPoolRange) -> Self { + Self { + id: Ok(value.id), + range: Ok(value.range), + time_created: Ok(value.time_created), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolRangeResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolRangeResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IpPoolRangeResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolRangeResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRangeResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IpPoolRangeResultsPage { + fn from(value: super::IpPoolRangeResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IpPoolResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IpPoolResultsPage { + fn from(value: super::IpPoolResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for IpPoolUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl IpPoolUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for IpPoolUpdate { + fn from(value: super::IpPoolUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Ipv4Range { + first: ::std::result::Result<::std::net::Ipv4Addr, ::std::string::String>, + last: ::std::result::Result<::std::net::Ipv4Addr, ::std::string::String>, + } + + impl ::std::default::Default for Ipv4Range { + fn default() -> Self { + Self { + first: Err("no value supplied for first".to_string()), + last: Err("no value supplied for last".to_string()), + } + } + } + + impl Ipv4Range { + pub fn first(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv4Addr>, + T::Error: ::std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn last(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv4Addr>, + T::Error: ::std::fmt::Display, + { + self.last = value + .try_into() + .map_err(|e| format!("error converting supplied value for last: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Ipv4Range { + type Error = super::error::ConversionError; + fn try_from( + value: Ipv4Range, + ) -> ::std::result::Result { + Ok(Self { + first: value.first?, + last: value.last?, + }) + } + } + + impl ::std::convert::From for Ipv4Range { + fn from(value: super::Ipv4Range) -> Self { + Self { + first: Ok(value.first), + last: Ok(value.last), + } + } + } + + #[derive(Clone, Debug)] + pub struct Ipv6Range { + first: ::std::result::Result<::std::net::Ipv6Addr, ::std::string::String>, + last: ::std::result::Result<::std::net::Ipv6Addr, ::std::string::String>, + } + + impl ::std::default::Default for Ipv6Range { + fn default() -> Self { + Self { + first: Err("no value supplied for first".to_string()), + last: Err("no value supplied for last".to_string()), + } + } + } + + impl Ipv6Range { + pub fn first(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv6Addr>, + T::Error: ::std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn last(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv6Addr>, + T::Error: ::std::fmt::Display, + { + self.last = value + .try_into() + .map_err(|e| format!("error converting supplied value for last: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Ipv6Range { + type Error = super::error::ConversionError; + fn try_from( + value: Ipv6Range, + ) -> ::std::result::Result { + Ok(Self { + first: value.first?, + last: value.last?, + }) + } + } + + impl ::std::convert::From for Ipv6Range { + fn from(value: super::Ipv6Range) -> Self { + Self { + first: Ok(value.first), + last: Ok(value.last), + } + } + } + + #[derive(Clone, Debug)] + pub struct Measurement { + datum: ::std::result::Result, + timestamp: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Measurement { + fn default() -> Self { + Self { + datum: Err("no value supplied for datum".to_string()), + timestamp: Err("no value supplied for timestamp".to_string()), + } + } + } + + impl Measurement { + pub fn datum(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.datum = value + .try_into() + .map_err(|e| format!("error converting supplied value for datum: {}", e)); + self + } + pub fn timestamp(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.timestamp = value + .try_into() + .map_err(|e| format!("error converting supplied value for timestamp: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Measurement { + type Error = super::error::ConversionError; + fn try_from( + value: Measurement, + ) -> ::std::result::Result { + Ok(Self { + datum: value.datum?, + timestamp: value.timestamp?, + }) + } + } + + impl ::std::convert::From for Measurement { + fn from(value: super::Measurement) -> Self { + Self { + datum: Ok(value.datum), + timestamp: Ok(value.timestamp), + } + } + } + + #[derive(Clone, Debug)] + pub struct MeasurementResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for MeasurementResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl MeasurementResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::MeasurementResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: MeasurementResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for MeasurementResultsPage { + fn from(value: super::MeasurementResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterface { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + instance_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ip: ::std::result::Result<::std::net::IpAddr, ::std::string::String>, + mac: ::std::result::Result, + name: ::std::result::Result, + primary: ::std::result::Result, + subnet_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for NetworkInterface { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + instance_id: Err("no value supplied for instance_id".to_string()), + ip: Err("no value supplied for ip".to_string()), + mac: Err("no value supplied for mac".to_string()), + name: Err("no value supplied for name".to_string()), + primary: Err("no value supplied for primary".to_string()), + subnet_id: Err("no value supplied for subnet_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl NetworkInterface { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn instance_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.instance_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); + self + } + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::IpAddr>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn mac(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.mac = value + .try_into() + .map_err(|e| format!("error converting supplied value for mac: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn primary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } + pub fn subnet_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.subnet_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for subnet_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterface { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterface, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + instance_id: value.instance_id?, + ip: value.ip?, + mac: value.mac?, + name: value.name?, + primary: value.primary?, + subnet_id: value.subnet_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for NetworkInterface { + fn from(value: super::NetworkInterface) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + instance_id: Ok(value.instance_id), + ip: Ok(value.ip), + mac: Ok(value.mac), + name: Ok(value.name), + primary: Ok(value.primary), + subnet_id: Ok(value.subnet_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + ip: ::std::result::Result< + ::std::option::Option<::std::net::IpAddr>, + ::std::string::String, + >, + name: ::std::result::Result, + subnet_name: ::std::result::Result, + vpc_name: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + ip: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + subnet_name: Err("no value supplied for subnet_name".to_string()), + vpc_name: Err("no value supplied for vpc_name".to_string()), + } + } + } + + impl NetworkInterfaceCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::net::IpAddr>>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn subnet_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.subnet_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for subnet_name: {}", e)); + self + } + pub fn vpc_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.vpc_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceCreate { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + ip: value.ip?, + name: value.name?, + subnet_name: value.subnet_name?, + vpc_name: value.vpc_name?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceCreate { + fn from(value: super::NetworkInterfaceCreate) -> Self { + Self { + description: Ok(value.description), + ip: Ok(value.ip), + name: Ok(value.name), + subnet_name: Ok(value.subnet_name), + vpc_name: Ok(value.vpc_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for NetworkInterfaceResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl NetworkInterfaceResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceResultsPage { + fn from(value: super::NetworkInterfaceResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + primary: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + primary: Ok(Default::default()), + } + } + } + + impl NetworkInterfaceUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn primary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + primary: value.primary?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceUpdate { + fn from(value: super::NetworkInterfaceUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + primary: Ok(value.primary), + } + } + } + + #[derive(Clone, Debug)] + pub struct Organization { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Organization { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Organization { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Organization { + type Error = super::error::ConversionError; + fn try_from( + value: Organization, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Organization { + fn from(value: super::Organization) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for OrganizationCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl OrganizationCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationCreate { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for OrganizationCreate { + fn from(value: super::OrganizationCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for OrganizationResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl OrganizationResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for OrganizationResultsPage { + fn from(value: super::OrganizationResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for OrganizationRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl OrganizationRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for OrganizationRolePolicy { + fn from(value: super::OrganizationRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for OrganizationRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl OrganizationRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::OrganizationRoleRoleAssignment + { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From + for OrganizationRoleRoleAssignment + { + fn from(value: super::OrganizationRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for OrganizationUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl OrganizationUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for OrganizationUpdate { + fn from(value: super::OrganizationUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct PhysicalDisk { + disk_type: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + model: ::std::result::Result<::std::string::String, ::std::string::String>, + serial: ::std::result::Result<::std::string::String, ::std::string::String>, + sled_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vendor: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for PhysicalDisk { + fn default() -> Self { + Self { + disk_type: Err("no value supplied for disk_type".to_string()), + id: Err("no value supplied for id".to_string()), + model: Err("no value supplied for model".to_string()), + serial: Err("no value supplied for serial".to_string()), + sled_id: Ok(Default::default()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vendor: Err("no value supplied for vendor".to_string()), + } + } + } + + impl PhysicalDisk { + pub fn disk_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_type: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn model(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.model = value + .try_into() + .map_err(|e| format!("error converting supplied value for model: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + pub fn sled_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for sled_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vendor(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.vendor = value + .try_into() + .map_err(|e| format!("error converting supplied value for vendor: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PhysicalDisk { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDisk, + ) -> ::std::result::Result { + Ok(Self { + disk_type: value.disk_type?, + id: value.id?, + model: value.model?, + serial: value.serial?, + sled_id: value.sled_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vendor: value.vendor?, + }) + } + } + + impl ::std::convert::From for PhysicalDisk { + fn from(value: super::PhysicalDisk) -> Self { + Self { + disk_type: Ok(value.disk_type), + id: Ok(value.id), + model: Ok(value.model), + serial: Ok(value.serial), + sled_id: Ok(value.sled_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vendor: Ok(value.vendor), + } + } + } + + #[derive(Clone, Debug)] + pub struct PhysicalDiskResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for PhysicalDiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl PhysicalDiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PhysicalDiskResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDiskResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for PhysicalDiskResultsPage { + fn from(value: super::PhysicalDiskResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Project { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + organization_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Project { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + organization_id: Err("no value supplied for organization_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Project { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn organization_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.organization_id = value.try_into().map_err(|e| { + format!("error converting supplied value for organization_id: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Project { + type Error = super::error::ConversionError; + fn try_from( + value: Project, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + organization_id: value.organization_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Project { + fn from(value: super::Project) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + organization_id: Ok(value.organization_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for ProjectCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl ProjectCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectCreate { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for ProjectCreate { + fn from(value: super::ProjectCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ProjectResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ProjectResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ProjectResultsPage { + fn from(value: super::ProjectResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for ProjectRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl ProjectRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for ProjectRolePolicy { + fn from(value: super::ProjectRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for ProjectRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl ProjectRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for ProjectRoleRoleAssignment { + fn from(value: super::ProjectRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for ProjectUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl ProjectUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for ProjectUpdate { + fn from(value: super::ProjectUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Rack { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Rack { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Rack { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Rack { + type Error = super::error::ConversionError; + fn try_from(value: Rack) -> ::std::result::Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Rack { + fn from(value: super::Rack) -> Self { + Self { + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct RackResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RackResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RackResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RackResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RackResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RackResultsPage { + fn from(value: super::RackResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Role { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for Role { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl Role { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Role { + type Error = super::error::ConversionError; + fn try_from(value: Role) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for Role { + fn from(value: super::Role) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct RoleResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RoleResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RoleResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RoleResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RoleResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RoleResultsPage { + fn from(value: super::RoleResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRoute { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + destination: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + kind: ::std::result::Result, + name: ::std::result::Result, + target: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_router_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for RouterRoute { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + destination: Err("no value supplied for destination".to_string()), + id: Err("no value supplied for id".to_string()), + kind: Err("no value supplied for kind".to_string()), + name: Err("no value supplied for name".to_string()), + target: Err("no value supplied for target".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_router_id: Err("no value supplied for vpc_router_id".to_string()), + } + } + } + + impl RouterRoute { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_router_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_router_id = value.try_into().map_err(|e| { + format!("error converting supplied value for vpc_router_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRoute { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRoute, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + id: value.id?, + kind: value.kind?, + name: value.name?, + target: value.target?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_router_id: value.vpc_router_id?, + }) + } + } + + impl ::std::convert::From for RouterRoute { + fn from(value: super::RouterRoute) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + id: Ok(value.id), + kind: Ok(value.kind), + name: Ok(value.name), + target: Ok(value.target), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_router_id: Ok(value.vpc_router_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteCreateParams { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + destination: ::std::result::Result, + name: ::std::result::Result, + target: ::std::result::Result, + } + + impl ::std::default::Default for RouterRouteCreateParams { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + destination: Err("no value supplied for destination".to_string()), + name: Err("no value supplied for name".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl RouterRouteCreateParams { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteCreateParams { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteCreateParams, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + name: value.name?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for RouterRouteCreateParams { + fn from(value: super::RouterRouteCreateParams) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + name: Ok(value.name), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RouterRouteResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RouterRouteResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RouterRouteResultsPage { + fn from(value: super::RouterRouteResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteUpdateParams { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + destination: ::std::result::Result, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + target: ::std::result::Result, + } + + impl ::std::default::Default for RouterRouteUpdateParams { + fn default() -> Self { + Self { + description: Ok(Default::default()), + destination: Err("no value supplied for destination".to_string()), + name: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl RouterRouteUpdateParams { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteUpdateParams { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteUpdateParams, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + name: value.name?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for RouterRouteUpdateParams { + fn from(value: super::RouterRouteUpdateParams) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + name: Ok(value.name), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct Saga { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + state: ::std::result::Result, + } + + impl ::std::default::Default for Saga { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Saga { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Saga { + type Error = super::error::ConversionError; + fn try_from(value: Saga) -> ::std::result::Result { + Ok(Self { + id: value.id?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Saga { + fn from(value: super::Saga) -> Self { + Self { + id: Ok(value.id), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct SagaResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SagaResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SagaResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SagaResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SagaResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SagaResultsPage { + fn from(value: super::SagaResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SamlIdentityProvider { + acs_url: ::std::result::Result<::std::string::String, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + idp_entity_id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + public_cert: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + slo_url: ::std::result::Result<::std::string::String, ::std::string::String>, + sp_client_id: ::std::result::Result<::std::string::String, ::std::string::String>, + technical_contact_email: + ::std::result::Result<::std::string::String, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SamlIdentityProvider { + fn default() -> Self { + Self { + acs_url: Err("no value supplied for acs_url".to_string()), + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), + name: Err("no value supplied for name".to_string()), + public_cert: Ok(Default::default()), + slo_url: Err("no value supplied for slo_url".to_string()), + sp_client_id: Err("no value supplied for sp_client_id".to_string()), + technical_contact_email: Err( + "no value supplied for technical_contact_email".to_string() + ), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl SamlIdentityProvider { + pub fn acs_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.acs_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for acs_url: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn idp_entity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.idp_entity_id = value.try_into().map_err(|e| { + format!("error converting supplied value for idp_entity_id: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.public_cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_cert: {}", e)); + self + } + pub fn slo_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.slo_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for slo_url: {}", e)); + self + } + pub fn sp_client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.sp_client_id = value.try_into().map_err(|e| { + format!("error converting supplied value for sp_client_id: {}", e) + }); + self + } + pub fn technical_contact_email(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.technical_contact_email = value.try_into().map_err(|e| { + format!( + "error converting supplied value for technical_contact_email: {}", + e + ) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SamlIdentityProvider { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProvider, + ) -> ::std::result::Result { + Ok(Self { + acs_url: value.acs_url?, + description: value.description?, + id: value.id?, + idp_entity_id: value.idp_entity_id?, + name: value.name?, + public_cert: value.public_cert?, + slo_url: value.slo_url?, + sp_client_id: value.sp_client_id?, + technical_contact_email: value.technical_contact_email?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for SamlIdentityProvider { + fn from(value: super::SamlIdentityProvider) -> Self { + Self { + acs_url: Ok(value.acs_url), + description: Ok(value.description), + id: Ok(value.id), + idp_entity_id: Ok(value.idp_entity_id), + name: Ok(value.name), + public_cert: Ok(value.public_cert), + slo_url: Ok(value.slo_url), + sp_client_id: Ok(value.sp_client_id), + technical_contact_email: Ok(value.technical_contact_email), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SamlIdentityProviderCreate { + acs_url: ::std::result::Result<::std::string::String, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + group_attribute_name: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + idp_entity_id: ::std::result::Result<::std::string::String, ::std::string::String>, + idp_metadata_source: + ::std::result::Result, + name: ::std::result::Result, + signing_keypair: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + slo_url: ::std::result::Result<::std::string::String, ::std::string::String>, + sp_client_id: ::std::result::Result<::std::string::String, ::std::string::String>, + technical_contact_email: + ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SamlIdentityProviderCreate { + fn default() -> Self { + Self { + acs_url: Err("no value supplied for acs_url".to_string()), + description: Err("no value supplied for description".to_string()), + group_attribute_name: Ok(Default::default()), + idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), + idp_metadata_source: Err( + "no value supplied for idp_metadata_source".to_string() + ), + name: Err("no value supplied for name".to_string()), + signing_keypair: Ok(Default::default()), + slo_url: Err("no value supplied for slo_url".to_string()), + sp_client_id: Err("no value supplied for sp_client_id".to_string()), + technical_contact_email: Err( + "no value supplied for technical_contact_email".to_string() + ), + } + } + } + + impl SamlIdentityProviderCreate { + pub fn acs_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.acs_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for acs_url: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn group_attribute_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.group_attribute_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for group_attribute_name: {}", + e + ) + }); + self + } + pub fn idp_entity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.idp_entity_id = value.try_into().map_err(|e| { + format!("error converting supplied value for idp_entity_id: {}", e) + }); + self + } + pub fn idp_metadata_source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.idp_metadata_source = value.try_into().map_err(|e| { + format!( + "error converting supplied value for idp_metadata_source: {}", + e + ) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn signing_keypair(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.signing_keypair = value.try_into().map_err(|e| { + format!("error converting supplied value for signing_keypair: {}", e) + }); + self + } + pub fn slo_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.slo_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for slo_url: {}", e)); + self + } + pub fn sp_client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.sp_client_id = value.try_into().map_err(|e| { + format!("error converting supplied value for sp_client_id: {}", e) + }); + self + } + pub fn technical_contact_email(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.technical_contact_email = value.try_into().map_err(|e| { + format!( + "error converting supplied value for technical_contact_email: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SamlIdentityProviderCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProviderCreate, + ) -> ::std::result::Result { + Ok(Self { + acs_url: value.acs_url?, + description: value.description?, + group_attribute_name: value.group_attribute_name?, + idp_entity_id: value.idp_entity_id?, + idp_metadata_source: value.idp_metadata_source?, + name: value.name?, + signing_keypair: value.signing_keypair?, + slo_url: value.slo_url?, + sp_client_id: value.sp_client_id?, + technical_contact_email: value.technical_contact_email?, + }) + } + } + + impl ::std::convert::From for SamlIdentityProviderCreate { + fn from(value: super::SamlIdentityProviderCreate) -> Self { + Self { + acs_url: Ok(value.acs_url), + description: Ok(value.description), + group_attribute_name: Ok(value.group_attribute_name), + idp_entity_id: Ok(value.idp_entity_id), + idp_metadata_source: Ok(value.idp_metadata_source), + name: Ok(value.name), + signing_keypair: Ok(value.signing_keypair), + slo_url: Ok(value.slo_url), + sp_client_id: Ok(value.sp_client_id), + technical_contact_email: Ok(value.technical_contact_email), + } + } + } + + #[derive(Clone, Debug)] + pub struct Silo { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + discoverable: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_mode: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Silo { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + discoverable: Err("no value supplied for discoverable".to_string()), + id: Err("no value supplied for id".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Silo { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn discoverable(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.discoverable = value.try_into().map_err(|e| { + format!("error converting supplied value for discoverable: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn identity_mode(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Silo { + type Error = super::error::ConversionError; + fn try_from(value: Silo) -> ::std::result::Result { + Ok(Self { + description: value.description?, + discoverable: value.discoverable?, + id: value.id?, + identity_mode: value.identity_mode?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Silo { + fn from(value: super::Silo) -> Self { + Self { + description: Ok(value.description), + discoverable: Ok(value.discoverable), + id: Ok(value.id), + identity_mode: Ok(value.identity_mode), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloCreate { + admin_group_name: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + discoverable: ::std::result::Result, + identity_mode: ::std::result::Result, + name: ::std::result::Result, + } + + impl ::std::default::Default for SiloCreate { + fn default() -> Self { + Self { + admin_group_name: Ok(Default::default()), + description: Err("no value supplied for description".to_string()), + discoverable: Err("no value supplied for discoverable".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl SiloCreate { + pub fn admin_group_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.admin_group_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for admin_group_name: {}", + e + ) + }); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn discoverable(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.discoverable = value.try_into().map_err(|e| { + format!("error converting supplied value for discoverable: {}", e) + }); + self + } + pub fn identity_mode(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SiloCreate, + ) -> ::std::result::Result { + Ok(Self { + admin_group_name: value.admin_group_name?, + description: value.description?, + discoverable: value.discoverable?, + identity_mode: value.identity_mode?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for SiloCreate { + fn from(value: super::SiloCreate) -> Self { + Self { + admin_group_name: Ok(value.admin_group_name), + description: Ok(value.description), + discoverable: Ok(value.discoverable), + identity_mode: Ok(value.identity_mode), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SiloResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SiloResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SiloResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SiloResultsPage { + fn from(value: super::SiloResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for SiloRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl SiloRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SiloRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for SiloRolePolicy { + fn from(value: super::SiloRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for SiloRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl SiloRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for SiloRoleRoleAssignment { + fn from(value: super::SiloRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Sled { + baseboard: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + service_address: ::std::result::Result<::std::string::String, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Sled { + fn default() -> Self { + Self { + baseboard: Err("no value supplied for baseboard".to_string()), + id: Err("no value supplied for id".to_string()), + service_address: Err("no value supplied for service_address".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Sled { + pub fn baseboard(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.baseboard = value + .try_into() + .map_err(|e| format!("error converting supplied value for baseboard: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn service_address(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.service_address = value.try_into().map_err(|e| { + format!("error converting supplied value for service_address: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Sled { + type Error = super::error::ConversionError; + fn try_from(value: Sled) -> ::std::result::Result { + Ok(Self { + baseboard: value.baseboard?, + id: value.id?, + service_address: value.service_address?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Sled { + fn from(value: super::Sled) -> Self { + Self { + baseboard: Ok(value.baseboard), + id: Ok(value.id), + service_address: Ok(value.service_address), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SledResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SledResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SledResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SledResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SledResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SledResultsPage { + fn from(value: super::SledResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Snapshot { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Snapshot { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk_id: Err("no value supplied for disk_id".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + state: Err("no value supplied for state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Snapshot { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.disk_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Snapshot { + type Error = super::error::ConversionError; + fn try_from( + value: Snapshot, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk_id: value.disk_id?, + id: value.id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + state: value.state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Snapshot { + fn from(value: super::Snapshot) -> Self { + Self { + description: Ok(value.description), + disk_id: Ok(value.disk_id), + id: Ok(value.id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + state: Ok(value.state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SnapshotCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk: ::std::result::Result, + name: ::std::result::Result, + } + + impl ::std::default::Default for SnapshotCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk: Err("no value supplied for disk".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl SnapshotCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SnapshotCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SnapshotCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk: value.disk?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for SnapshotCreate { + fn from(value: super::SnapshotCreate) -> Self { + Self { + description: Ok(value.description), + disk: Ok(value.disk), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct SnapshotResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SnapshotResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SnapshotResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SnapshotResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SnapshotResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SnapshotResultsPage { + fn from(value: super::SnapshotResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SpoofLoginBody { + username: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SpoofLoginBody { + fn default() -> Self { + Self { + username: Err("no value supplied for username".to_string()), + } + } + } + + impl SpoofLoginBody { + pub fn username(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SpoofLoginBody { + type Error = super::error::ConversionError; + fn try_from( + value: SpoofLoginBody, + ) -> ::std::result::Result { + Ok(Self { + username: value.username?, + }) + } + } + + impl ::std::convert::From for SpoofLoginBody { + fn from(value: super::SpoofLoginBody) -> Self { + Self { + username: Ok(value.username), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKey { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + public_key: ::std::result::Result<::std::string::String, ::std::string::String>, + silo_user_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SshKey { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + public_key: Err("no value supplied for public_key".to_string()), + silo_user_id: Err("no value supplied for silo_user_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl SshKey { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_key: {}", e)); + self + } + pub fn silo_user_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_user_id = value.try_into().map_err(|e| { + format!("error converting supplied value for silo_user_id: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SshKey { + type Error = super::error::ConversionError; + fn try_from( + value: SshKey, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + public_key: value.public_key?, + silo_user_id: value.silo_user_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for SshKey { + fn from(value: super::SshKey) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + public_key: Ok(value.public_key), + silo_user_id: Ok(value.silo_user_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKeyCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + public_key: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SshKeyCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + public_key: Err("no value supplied for public_key".to_string()), + } + } + } + + impl SshKeyCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_key: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SshKeyCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SshKeyCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + public_key: value.public_key?, + }) + } + } + + impl ::std::convert::From for SshKeyCreate { + fn from(value: super::SshKeyCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + public_key: Ok(value.public_key), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKeyResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SshKeyResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SshKeyResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SshKeyResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SshKeyResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SshKeyResultsPage { + fn from(value: super::SshKeyResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdate { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for SystemUpdate { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdate { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdate, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for SystemUpdate { + fn from(value: super::SystemUpdate) -> Self { + Self { + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdateResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SystemUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SystemUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SystemUpdateResultsPage { + fn from(value: super::SystemUpdateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdateStart { + version: ::std::result::Result, + } + + impl ::std::default::Default for SystemUpdateStart { + fn default() -> Self { + Self { + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdateStart { + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdateStart { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateStart, + ) -> ::std::result::Result { + Ok(Self { + version: value.version?, + }) + } + } + + impl ::std::convert::From for SystemUpdateStart { + fn from(value: super::SystemUpdateStart) -> Self { + Self { + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemVersion { + status: ::std::result::Result, + version_range: ::std::result::Result, + } + + impl ::std::default::Default for SystemVersion { + fn default() -> Self { + Self { + status: Err("no value supplied for status".to_string()), + version_range: Err("no value supplied for version_range".to_string()), + } + } + } + + impl SystemVersion { + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn version_range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version_range = value.try_into().map_err(|e| { + format!("error converting supplied value for version_range: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SystemVersion { + type Error = super::error::ConversionError; + fn try_from( + value: SystemVersion, + ) -> ::std::result::Result { + Ok(Self { + status: value.status?, + version_range: value.version_range?, + }) + } + } + + impl ::std::convert::From for SystemVersion { + fn from(value: super::SystemVersion) -> Self { + Self { + status: Ok(value.status), + version_range: Ok(value.version_range), + } + } + } + + #[derive(Clone, Debug)] + pub struct TimeseriesSchema { + created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + datum_type: ::std::result::Result, + field_schema: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + timeseries_name: ::std::result::Result, + } + + impl ::std::default::Default for TimeseriesSchema { + fn default() -> Self { + Self { + created: Err("no value supplied for created".to_string()), + datum_type: Err("no value supplied for datum_type".to_string()), + field_schema: Err("no value supplied for field_schema".to_string()), + timeseries_name: Err("no value supplied for timeseries_name".to_string()), + } + } + } + + impl TimeseriesSchema { + pub fn created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.created = value + .try_into() + .map_err(|e| format!("error converting supplied value for created: {}", e)); + self + } + pub fn datum_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.datum_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for datum_type: {}", e)); + self + } + pub fn field_schema(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.field_schema = value.try_into().map_err(|e| { + format!("error converting supplied value for field_schema: {}", e) + }); + self + } + pub fn timeseries_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.timeseries_name = value.try_into().map_err(|e| { + format!("error converting supplied value for timeseries_name: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::TimeseriesSchema { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchema, + ) -> ::std::result::Result { + Ok(Self { + created: value.created?, + datum_type: value.datum_type?, + field_schema: value.field_schema?, + timeseries_name: value.timeseries_name?, + }) + } + } + + impl ::std::convert::From for TimeseriesSchema { + fn from(value: super::TimeseriesSchema) -> Self { + Self { + created: Ok(value.created), + datum_type: Ok(value.datum_type), + field_schema: Ok(value.field_schema), + timeseries_name: Ok(value.timeseries_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct TimeseriesSchemaResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for TimeseriesSchemaResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl TimeseriesSchemaResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TimeseriesSchemaResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchemaResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for TimeseriesSchemaResultsPage { + fn from(value: super::TimeseriesSchemaResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateDeployment { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + status: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for UpdateDeployment { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateDeployment { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateDeployment { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeployment, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + status: value.status?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for UpdateDeployment { + fn from(value: super::UpdateDeployment) -> Self { + Self { + id: Ok(value.id), + status: Ok(value.status), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateDeploymentResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UpdateDeploymentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateDeploymentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateDeploymentResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeploymentResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UpdateDeploymentResultsPage { + fn from(value: super::UpdateDeploymentResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateableComponent { + component_type: + ::std::result::Result, + device_id: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + status: ::std::result::Result, + system_version: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for UpdateableComponent { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + device_id: Err("no value supplied for device_id".to_string()), + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + system_version: Err("no value supplied for system_version".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateableComponent { + pub fn component_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn device_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn system_version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.system_version = value.try_into().map_err(|e| { + format!("error converting supplied value for system_version: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateableComponent { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponent, + ) -> ::std::result::Result { + Ok(Self { + component_type: value.component_type?, + device_id: value.device_id?, + id: value.id?, + status: value.status?, + system_version: value.system_version?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for UpdateableComponent { + fn from(value: super::UpdateableComponent) -> Self { + Self { + component_type: Ok(value.component_type), + device_id: Ok(value.device_id), + id: Ok(value.id), + status: Ok(value.status), + system_version: Ok(value.system_version), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateableComponentResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UpdateableComponentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateableComponentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::UpdateableComponentResultsPage + { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponentResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From + for UpdateableComponentResultsPage + { + fn from(value: super::UpdateableComponentResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct User { + display_name: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + silo_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for User { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl User { + pub fn display_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::User { + type Error = super::error::ConversionError; + fn try_from(value: User) -> ::std::result::Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + impl ::std::convert::From for User { + fn from(value: super::User) -> Self { + Self { + display_name: Ok(value.display_name), + id: Ok(value.id), + silo_id: Ok(value.silo_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserBuiltin { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserBuiltin { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl UserBuiltin { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::UserBuiltin { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltin, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for UserBuiltin { + fn from(value: super::UserBuiltin) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserBuiltinResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserBuiltinResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UserBuiltinResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserBuiltinResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltinResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UserBuiltinResultsPage { + fn from(value: super::UserBuiltinResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + external_id: ::std::result::Result, + password: ::std::result::Result, + } + + impl ::std::default::Default for UserCreate { + fn default() -> Self { + Self { + external_id: Err("no value supplied for external_id".to_string()), + password: Err("no value supplied for password".to_string()), + } + } + } + + impl UserCreate { + pub fn external_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.external_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for external_id: {}", e)); + self + } + pub fn password(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreate { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreate, + ) -> ::std::result::Result { + Ok(Self { + external_id: value.external_id?, + password: value.password?, + }) + } + } + + impl ::std::convert::From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + external_id: Ok(value.external_id), + password: Ok(value.password), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UserResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UserResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UserResultsPage { + fn from(value: super::UserResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UsernamePasswordCredentials { + password: ::std::result::Result, + username: ::std::result::Result, + } + + impl ::std::default::Default for UsernamePasswordCredentials { + fn default() -> Self { + Self { + password: Err("no value supplied for password".to_string()), + username: Err("no value supplied for username".to_string()), + } + } + } + + impl UsernamePasswordCredentials { + pub fn password(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + pub fn username(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UsernamePasswordCredentials { + type Error = super::error::ConversionError; + fn try_from( + value: UsernamePasswordCredentials, + ) -> ::std::result::Result { + Ok(Self { + password: value.password?, + username: value.username?, + }) + } + } + + impl ::std::convert::From for UsernamePasswordCredentials { + fn from(value: super::UsernamePasswordCredentials) -> Self { + Self { + password: Ok(value.password), + username: Ok(value.username), + } + } + } + + #[derive(Clone, Debug)] + pub struct VersionRange { + high: ::std::result::Result, + low: ::std::result::Result, + } + + impl ::std::default::Default for VersionRange { + fn default() -> Self { + Self { + high: Err("no value supplied for high".to_string()), + low: Err("no value supplied for low".to_string()), + } + } + } + + impl VersionRange { + pub fn high(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.high = value + .try_into() + .map_err(|e| format!("error converting supplied value for high: {}", e)); + self + } + pub fn low(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.low = value + .try_into() + .map_err(|e| format!("error converting supplied value for low: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VersionRange { + type Error = super::error::ConversionError; + fn try_from( + value: VersionRange, + ) -> ::std::result::Result { + Ok(Self { + high: value.high?, + low: value.low?, + }) + } + } + + impl ::std::convert::From for VersionRange { + fn from(value: super::VersionRange) -> Self { + Self { + high: Ok(value.high), + low: Ok(value.low), + } + } + } + + #[derive(Clone, Debug)] + pub struct Vpc { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + dns_name: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ipv6_prefix: ::std::result::Result, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + system_router_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Vpc { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + dns_name: Err("no value supplied for dns_name".to_string()), + id: Err("no value supplied for id".to_string()), + ipv6_prefix: Err("no value supplied for ipv6_prefix".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + system_router_id: Err("no value supplied for system_router_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Vpc { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn ipv6_prefix(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv6_prefix = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_prefix: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn system_router_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.system_router_id = value.try_into().map_err(|e| { + format!( + "error converting supplied value for system_router_id: {}", + e + ) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Vpc { + type Error = super::error::ConversionError; + fn try_from(value: Vpc) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + id: value.id?, + ipv6_prefix: value.ipv6_prefix?, + name: value.name?, + project_id: value.project_id?, + system_router_id: value.system_router_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Vpc { + fn from(value: super::Vpc) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + id: Ok(value.id), + ipv6_prefix: Ok(value.ipv6_prefix), + name: Ok(value.name), + project_id: Ok(value.project_id), + system_router_id: Ok(value.system_router_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + dns_name: ::std::result::Result, + ipv6_prefix: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + dns_name: Err("no value supplied for dns_name".to_string()), + ipv6_prefix: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn ipv6_prefix(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.ipv6_prefix = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_prefix: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + ipv6_prefix: value.ipv6_prefix?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcCreate { + fn from(value: super::VpcCreate) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + ipv6_prefix: Ok(value.ipv6_prefix), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRule { + action: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + direction: + ::std::result::Result, + filters: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + priority: ::std::result::Result, + status: ::std::result::Result, + targets: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcFirewallRule { + fn default() -> Self { + Self { + action: Err("no value supplied for action".to_string()), + description: Err("no value supplied for description".to_string()), + direction: Err("no value supplied for direction".to_string()), + filters: Err("no value supplied for filters".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + priority: Err("no value supplied for priority".to_string()), + status: Err("no value supplied for status".to_string()), + targets: Err("no value supplied for targets".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcFirewallRule { + pub fn action(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.action = value + .try_into() + .map_err(|e| format!("error converting supplied value for action: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn direction(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.direction = value + .try_into() + .map_err(|e| format!("error converting supplied value for direction: {}", e)); + self + } + pub fn filters(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.filters = value + .try_into() + .map_err(|e| format!("error converting supplied value for filters: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn priority(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.priority = value + .try_into() + .map_err(|e| format!("error converting supplied value for priority: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn targets(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.targets = value + .try_into() + .map_err(|e| format!("error converting supplied value for targets: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRule { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRule, + ) -> ::std::result::Result { + Ok(Self { + action: value.action?, + description: value.description?, + direction: value.direction?, + filters: value.filters?, + id: value.id?, + name: value.name?, + priority: value.priority?, + status: value.status?, + targets: value.targets?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRule { + fn from(value: super::VpcFirewallRule) -> Self { + Self { + action: Ok(value.action), + description: Ok(value.description), + direction: Ok(value.direction), + filters: Ok(value.filters), + id: Ok(value.id), + name: Ok(value.name), + priority: Ok(value.priority), + status: Ok(value.status), + targets: Ok(value.targets), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleFilter { + hosts: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + ports: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + protocols: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleFilter { + fn default() -> Self { + Self { + hosts: Ok(Default::default()), + ports: Ok(Default::default()), + protocols: Ok(Default::default()), + } + } + } + + impl VpcFirewallRuleFilter { + pub fn hosts(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.hosts = value + .try_into() + .map_err(|e| format!("error converting supplied value for hosts: {}", e)); + self + } + pub fn ports(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.ports = value + .try_into() + .map_err(|e| format!("error converting supplied value for ports: {}", e)); + self + } + pub fn protocols(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.protocols = value + .try_into() + .map_err(|e| format!("error converting supplied value for protocols: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleFilter { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleFilter, + ) -> ::std::result::Result { + Ok(Self { + hosts: value.hosts?, + ports: value.ports?, + protocols: value.protocols?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleFilter { + fn from(value: super::VpcFirewallRuleFilter) -> Self { + Self { + hosts: Ok(value.hosts), + ports: Ok(value.ports), + protocols: Ok(value.protocols), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleUpdate { + action: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + direction: + ::std::result::Result, + filters: ::std::result::Result, + name: ::std::result::Result, + priority: ::std::result::Result, + status: ::std::result::Result, + targets: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleUpdate { + fn default() -> Self { + Self { + action: Err("no value supplied for action".to_string()), + description: Err("no value supplied for description".to_string()), + direction: Err("no value supplied for direction".to_string()), + filters: Err("no value supplied for filters".to_string()), + name: Err("no value supplied for name".to_string()), + priority: Err("no value supplied for priority".to_string()), + status: Err("no value supplied for status".to_string()), + targets: Err("no value supplied for targets".to_string()), + } + } + } + + impl VpcFirewallRuleUpdate { + pub fn action(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.action = value + .try_into() + .map_err(|e| format!("error converting supplied value for action: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn direction(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.direction = value + .try_into() + .map_err(|e| format!("error converting supplied value for direction: {}", e)); + self + } + pub fn filters(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.filters = value + .try_into() + .map_err(|e| format!("error converting supplied value for filters: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn priority(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.priority = value + .try_into() + .map_err(|e| format!("error converting supplied value for priority: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn targets(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.targets = value + .try_into() + .map_err(|e| format!("error converting supplied value for targets: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdate, + ) -> ::std::result::Result { + Ok(Self { + action: value.action?, + description: value.description?, + direction: value.direction?, + filters: value.filters?, + name: value.name?, + priority: value.priority?, + status: value.status?, + targets: value.targets?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleUpdate { + fn from(value: super::VpcFirewallRuleUpdate) -> Self { + Self { + action: Ok(value.action), + description: Ok(value.description), + direction: Ok(value.direction), + filters: Ok(value.filters), + name: Ok(value.name), + priority: Ok(value.priority), + status: Ok(value.status), + targets: Ok(value.targets), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleUpdateParams { + rules: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleUpdateParams { + fn default() -> Self { + Self { + rules: Err("no value supplied for rules".to_string()), + } + } + } + + impl VpcFirewallRuleUpdateParams { + pub fn rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.rules = value + .try_into() + .map_err(|e| format!("error converting supplied value for rules: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdateParams, + ) -> ::std::result::Result { + Ok(Self { + rules: value.rules?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleUpdateParams { + fn from(value: super::VpcFirewallRuleUpdateParams) -> Self { + Self { + rules: Ok(value.rules), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRules { + rules: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRules { + fn default() -> Self { + Self { + rules: Err("no value supplied for rules".to_string()), + } + } + } + + impl VpcFirewallRules { + pub fn rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.rules = value + .try_into() + .map_err(|e| format!("error converting supplied value for rules: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRules { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRules, + ) -> ::std::result::Result { + Ok(Self { + rules: value.rules?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRules { + fn from(value: super::VpcFirewallRules) -> Self { + Self { + rules: Ok(value.rules), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcResultsPage { + fn from(value: super::VpcResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouter { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + kind: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcRouter { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + kind: Err("no value supplied for kind".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcRouter { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouter { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouter, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + kind: value.kind?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcRouter { + fn from(value: super::VpcRouter) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + kind: Ok(value.kind), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcRouterCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcRouterCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcRouterCreate { + fn from(value: super::VpcRouterCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcRouterResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcRouterResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcRouterResultsPage { + fn from(value: super::VpcRouterResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcRouterUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcRouterUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcRouterUpdate { + fn from(value: super::VpcRouterUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnet { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ipv4_block: ::std::result::Result, + ipv6_block: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcSubnet { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + ipv4_block: Err("no value supplied for ipv4_block".to_string()), + ipv6_block: Err("no value supplied for ipv6_block".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcSubnet { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn ipv4_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv4_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv4_block: {}", e)); + self + } + pub fn ipv6_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv6_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_block: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnet { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnet, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + ipv4_block: value.ipv4_block?, + ipv6_block: value.ipv6_block?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcSubnet { + fn from(value: super::VpcSubnet) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + ipv4_block: Ok(value.ipv4_block), + ipv6_block: Ok(value.ipv6_block), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + ipv4_block: ::std::result::Result, + ipv6_block: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcSubnetCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + ipv4_block: Err("no value supplied for ipv4_block".to_string()), + ipv6_block: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcSubnetCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn ipv4_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv4_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv4_block: {}", e)); + self + } + pub fn ipv6_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.ipv6_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_block: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + ipv4_block: value.ipv4_block?, + ipv6_block: value.ipv6_block?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcSubnetCreate { + fn from(value: super::VpcSubnetCreate) -> Self { + Self { + description: Ok(value.description), + ipv4_block: Ok(value.ipv4_block), + ipv6_block: Ok(value.ipv6_block), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcSubnetResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcSubnetResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcSubnetResultsPage { + fn from(value: super::VpcSubnetResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcSubnetUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcSubnetUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcSubnetUpdate { + fn from(value: super::VpcSubnetUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + dns_name: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + dns_name: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcUpdate { + fn from(value: super::VpcUpdate) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + name: Ok(value.name), + } + } + } + } + + /// Generation of default values for serde. + pub mod defaults { + pub(super) fn default_bool() -> bool { + V + } + + pub(super) fn instance_create_network_interfaces( + ) -> super::InstanceNetworkInterfaceAttachment { + super::InstanceNetworkInterfaceAttachment::Default + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to `/by-id/disks/{id}` + /// + ///```ignore + /// let response = client.disk_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn disk_view_by_id(&self) -> builder::DiskViewById<'_> { + builder::DiskViewById::new(self) + } + + ///Fetch an image by id + /// + ///Sends a `GET` request to `/by-id/images/{id}` + /// + ///```ignore + /// let response = client.image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn image_view_by_id(&self) -> builder::ImageViewById<'_> { + builder::ImageViewById::new(self) + } + + ///Fetch an instance by id + /// + ///Sends a `GET` request to `/by-id/instances/{id}` + /// + ///```ignore + /// let response = client.instance_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn instance_view_by_id(&self) -> builder::InstanceViewById<'_> { + builder::InstanceViewById::new(self) + } + + ///Fetch a network interface by id + /// + ///Sends a `GET` request to `/by-id/network-interfaces/{id}` + /// + ///```ignore + /// let response = client.instance_network_interface_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_view_by_id( + &self, + ) -> builder::InstanceNetworkInterfaceViewById<'_> { + builder::InstanceNetworkInterfaceViewById::new(self) + } + + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/by-id/organizations/{id}` + /// + ///```ignore + /// let response = client.organization_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn organization_view_by_id(&self) -> builder::OrganizationViewById<'_> { + builder::OrganizationViewById::new(self) + } + + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to `/by-id/projects/{id}` + /// + ///```ignore + /// let response = client.project_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn project_view_by_id(&self) -> builder::ProjectViewById<'_> { + builder::ProjectViewById::new(self) + } + + ///Fetch a snapshot by id + /// + ///Sends a `GET` request to `/by-id/snapshots/{id}` + /// + ///```ignore + /// let response = client.snapshot_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn snapshot_view_by_id(&self) -> builder::SnapshotViewById<'_> { + builder::SnapshotViewById::new(self) + } + + ///Fetch a route by id + /// + ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` + /// + ///```ignore + /// let response = client.vpc_router_route_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_view_by_id(&self) -> builder::VpcRouterRouteViewById<'_> { + builder::VpcRouterRouteViewById::new(self) + } + + ///Get a router by id + /// + ///Sends a `GET` request to `/by-id/vpc-routers/{id}` + /// + ///```ignore + /// let response = client.vpc_router_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_view_by_id(&self) -> builder::VpcRouterViewById<'_> { + builder::VpcRouterViewById::new(self) + } + + ///Fetch a subnet by id + /// + ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` + /// + ///```ignore + /// let response = client.vpc_subnet_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_view_by_id(&self) -> builder::VpcSubnetViewById<'_> { + builder::VpcSubnetViewById::new(self) + } + + ///Fetch a VPC + /// + ///Sends a `GET` request to `/by-id/vpcs/{id}` + /// + ///```ignore + /// let response = client.vpc_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn vpc_view_by_id(&self) -> builder::VpcViewById<'_> { + builder::VpcViewById::new(self) + } + + ///Start an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed from an *unauthenticated* API + /// client. It generates and records a `device_code` and `user_code` which + /// must be verified and confirmed prior to a token being granted. + /// + ///Sends a `POST` request to `/device/auth` + /// + ///```ignore + /// let response = client.device_auth_request() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn device_auth_request(&self) -> builder::DeviceAuthRequest<'_> { + builder::DeviceAuthRequest::new(self) + } + + ///Confirm an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed by the user agent (browser), + /// not the client requesting the token. So we do not actually return the + /// token here; it will be returned in response to the poll on + /// `/device/token`. + /// + ///Sends a `POST` request to `/device/confirm` + /// + ///```ignore + /// let response = client.device_auth_confirm() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn device_auth_confirm(&self) -> builder::DeviceAuthConfirm<'_> { + builder::DeviceAuthConfirm::new(self) + } + + ///Request a device access token + /// + ///This endpoint should be polled by the client until the user code is + /// verified and the grant is confirmed. + /// + ///Sends a `POST` request to `/device/token` + /// + ///```ignore + /// let response = client.device_access_token() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn device_access_token(&self) -> builder::DeviceAccessToken<'_> { + builder::DeviceAccessToken::new(self) + } + + ///List groups + /// + ///Sends a `GET` request to `/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.group_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn group_list(&self) -> builder::GroupList<'_> { + builder::GroupList::new(self) + } + + ///Sends a `POST` request to `/login` + /// + ///```ignore + /// let response = client.login_spoof() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn login_spoof(&self) -> builder::LoginSpoof<'_> { + builder::LoginSpoof::new(self) + } + + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + /// + ///```ignore + /// let response = client.login_local() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn login_local(&self) -> builder::LoginLocal<'_> { + builder::LoginLocal::new(self) + } + + ///Prompt user login + /// + ///Either display a page asking a user for their credentials, or redirect + /// them to their identity provider. + /// + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + /// + ///```ignore + /// let response = client.login_saml_begin() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + pub fn login_saml_begin(&self) -> builder::LoginSamlBegin<'_> { + builder::LoginSamlBegin::new(self) + } + + ///Authenticate a user (i.e., log in) via SAML + /// + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + /// + ///```ignore + /// let response = client.login_saml() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn login_saml(&self) -> builder::LoginSaml<'_> { + builder::LoginSaml::new(self) + } + + ///Sends a `POST` request to `/logout` + /// + ///```ignore + /// let response = client.logout() + /// .send() + /// .await; + /// ``` + pub fn logout(&self) -> builder::Logout<'_> { + builder::Logout::new(self) + } + + ///List organizations + /// + ///Use `GET /v1/organizations` instead + /// + ///Sends a `GET` request to `/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn organization_list(&self) -> builder::OrganizationList<'_> { + builder::OrganizationList::new(self) + } + + ///Create an organization + /// + ///Use `POST /v1/organizations` instead + /// + ///Sends a `POST` request to `/organizations` + /// + ///```ignore + /// let response = client.organization_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_create(&self) -> builder::OrganizationCreate<'_> { + builder::OrganizationCreate::new(self) + } + + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_view() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organization_view(&self) -> builder::OrganizationView<'_> { + builder::OrganizationView::new(self) + } + + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.organization_update() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_update(&self) -> builder::OrganizationUpdate<'_> { + builder::OrganizationUpdate::new(self) + } + + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_delete() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organization_delete(&self) -> builder::OrganizationDelete<'_> { + builder::OrganizationDelete::new(self) + } + + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_policy_view() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_view(&self) -> builder::OrganizationPolicyView<'_> { + builder::OrganizationPolicyView::new(self) + } + + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.organization_policy_update() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_update(&self) -> builder::OrganizationPolicyUpdate<'_> { + builder::OrganizationPolicyUpdate::new(self) + } + + ///List projects + /// + ///Use `GET /v1/projects` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list() + /// .organization_name(organization_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_list(&self) -> builder::ProjectList<'_> { + builder::ProjectList::new(self) + } + + ///Create a project + /// + ///Use `POST /v1/projects` instead + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.project_create() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_create(&self) -> builder::ProjectCreate<'_> { + builder::ProjectCreate::new(self) + } + + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn project_view(&self) -> builder::ProjectView<'_> { + builder::ProjectView::new(self) + } + + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.project_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_update(&self) -> builder::ProjectUpdate<'_> { + builder::ProjectUpdate::new(self) + } + + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn project_delete(&self) -> builder::ProjectDelete<'_> { + builder::ProjectDelete::new(self) + } + + ///List disks + /// + ///Use `GET /v1/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.disk_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn disk_list(&self) -> builder::DiskList<'_> { + builder::DiskList::new(self) + } + + ///Use `POST /v1/disks` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.disk_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn disk_create(&self) -> builder::DiskCreate<'_> { + builder::DiskCreate::new(self) + } + + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + /// + ///```ignore + /// let response = client.disk_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + pub fn disk_view(&self) -> builder::DiskView<'_> { + builder::DiskView::new(self) + } + + ///Use `DELETE /v1/disks/{disk}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + /// + ///```ignore + /// let response = client.disk_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + pub fn disk_delete(&self) -> builder::DiskDelete<'_> { + builder::DiskDelete::new(self) + } + + ///Fetch disk metrics + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `disk_name` + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.disk_metrics_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + pub fn disk_metrics_list(&self) -> builder::DiskMetricsList<'_> { + builder::DiskMetricsList::new(self) + } + + ///List images + /// + ///List images in a project. The images are returned sorted by creation + /// date, with the most recent images appearing first. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.image_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn image_list(&self) -> builder::ImageList<'_> { + builder::ImageList::new(self) + } + + ///Create an image + /// + ///Create a new image in a project. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.image_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn image_create(&self) -> builder::ImageCreate<'_> { + builder::ImageCreate::new(self) + } + + ///Fetch an image + /// + ///Fetch the details for a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + /// + ///```ignore + /// let response = client.image_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn image_view(&self) -> builder::ImageView<'_> { + builder::ImageView::new(self) + } + + ///Delete an image + /// + ///Permanently delete an image from a project. This operation cannot be + /// undone. Any instances in the project using the image will continue to + /// run, however new instances can not be created with this image. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + /// + ///```ignore + /// let response = client.image_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn image_delete(&self) -> builder::ImageDelete<'_> { + builder::ImageDelete::new(self) + } + + ///List instances + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_list(&self) -> builder::InstanceList<'_> { + builder::InstanceList::new(self) + } + + ///Create an instance + /// + ///Use `POST /v1/instances` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.instance_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_create(&self) -> builder::InstanceCreate<'_> { + builder::InstanceCreate::new(self) + } + + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + /// + ///```ignore + /// let response = client.instance_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_view(&self) -> builder::InstanceView<'_> { + builder::InstanceView::new(self) + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + /// + ///```ignore + /// let response = client.instance_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_delete(&self) -> builder::InstanceDelete<'_> { + builder::InstanceDelete::new(self) + } + + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_list(&self) -> builder::InstanceDiskList<'_> { + builder::InstanceDiskList::new(self) + } + + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_attach(&self) -> builder::InstanceDiskAttach<'_> { + builder::InstanceDiskAttach::new(self) + } + + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_detach(&self) -> builder::InstanceDiskDetach<'_> { + builder::InstanceDiskDetach::new(self) + } + + ///List external IP addresses + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/external-ips` + /// + ///```ignore + /// let response = client.instance_external_ip_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_external_ip_list(&self) -> builder::InstanceExternalIpList<'_> { + builder::InstanceExternalIpList::new(self) + } + + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_migrate(&self) -> builder::InstanceMigrate<'_> { + builder::InstanceMigrate::new(self) + } + + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_network_interface_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_list(&self) -> builder::InstanceNetworkInterfaceList<'_> { + builder::InstanceNetworkInterfaceList::new(self) + } + + ///Create a network interface + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + /// + ///```ignore + /// let response = client.instance_network_interface_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_create(&self) -> builder::InstanceNetworkInterfaceCreate<'_> { + builder::InstanceNetworkInterfaceCreate::new(self) + } + + ///Fetch a network interface + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_view(&self) -> builder::InstanceNetworkInterfaceView<'_> { + builder::InstanceNetworkInterfaceView::new(self) + } + + ///Update a network interface + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_update(&self) -> builder::InstanceNetworkInterfaceUpdate<'_> { + builder::InstanceNetworkInterfaceUpdate::new(self) + } + + ///Delete a network interface + /// + ///Note that the primary interface for an instance cannot be deleted if + /// there are any secondary interfaces. A new primary interface must be + /// designated first. The primary interface can be deleted if there are no + /// secondary interfaces. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interface_delete(&self) -> builder::InstanceNetworkInterfaceDelete<'_> { + builder::InstanceNetworkInterfaceDelete::new(self) + } + + ///Reboot an instance + /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_reboot(&self) -> builder::InstanceReboot<'_> { + builder::InstanceReboot::new(self) + } + + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + ///```ignore + /// let response = client.instance_serial_console() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console(&self) -> builder::InstanceSerialConsole<'_> { + builder::InstanceSerialConsole::new(self) + } + + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream<'_> { + builder::InstanceSerialConsoleStream::new(self) + } + + ///Boot an instance + /// + ///Use `POST /v1/instances/{instance}/start` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` + /// + ///```ignore + /// let response = client.instance_start() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_start(&self) -> builder::InstanceStart<'_> { + builder::InstanceStart::new(self) + } + + ///Halt an instance + /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` + /// + ///```ignore + /// let response = client.instance_stop() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn instance_stop(&self) -> builder::InstanceStop<'_> { + builder::InstanceStop::new(self) + } + + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_policy_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn project_policy_view(&self) -> builder::ProjectPolicyView<'_> { + builder::ProjectPolicyView::new(self) + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.project_policy_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_policy_update(&self) -> builder::ProjectPolicyUpdate<'_> { + builder::ProjectPolicyUpdate::new(self) + } + + ///List snapshots + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.snapshot_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn snapshot_list(&self) -> builder::SnapshotList<'_> { + builder::SnapshotList::new(self) + } + + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.snapshot_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn snapshot_create(&self) -> builder::SnapshotCreate<'_> { + builder::SnapshotCreate::new(self) + } + + ///Fetch a snapshot + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + /// + ///```ignore + /// let response = client.snapshot_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + pub fn snapshot_view(&self) -> builder::SnapshotView<'_> { + builder::SnapshotView::new(self) + } + + ///Delete a snapshot + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + /// + ///```ignore + /// let response = client.snapshot_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + pub fn snapshot_delete(&self) -> builder::SnapshotDelete<'_> { + builder::SnapshotDelete::new(self) + } + + ///List VPCs + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn vpc_list(&self) -> builder::VpcList<'_> { + builder::VpcList::new(self) + } + + ///Create a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.vpc_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_create(&self) -> builder::VpcCreate<'_> { + builder::VpcCreate::new(self) + } + + ///Fetch a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_view(&self) -> builder::VpcView<'_> { + builder::VpcView::new(self) + } + + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_update(&self) -> builder::VpcUpdate<'_> { + builder::VpcUpdate::new(self) + } + + ///Delete a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_delete(&self) -> builder::VpcDelete<'_> { + builder::VpcDelete::new(self) + } + + ///List firewall rules + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + /// + ///```ignore + /// let response = client.vpc_firewall_rules_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_firewall_rules_view(&self) -> builder::VpcFirewallRulesView<'_> { + builder::VpcFirewallRulesView::new(self) + } + + ///Replace firewall rules + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + /// + ///```ignore + /// let response = client.vpc_firewall_rules_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_firewall_rules_update(&self) -> builder::VpcFirewallRulesUpdate<'_> { + builder::VpcFirewallRulesUpdate::new(self) + } + + ///List routers + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_router_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_list(&self) -> builder::VpcRouterList<'_> { + builder::VpcRouterList::new(self) + } + + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + /// + ///```ignore + /// let response = client.vpc_router_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_create(&self) -> builder::VpcRouterCreate<'_> { + builder::VpcRouterCreate::new(self) + } + + ///Get a router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_view(&self) -> builder::VpcRouterView<'_> { + builder::VpcRouterView::new(self) + } + + ///Update a router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_update(&self) -> builder::VpcRouterUpdate<'_> { + builder::VpcRouterUpdate::new(self) + } + + ///Delete a router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_delete(&self) -> builder::VpcRouterDelete<'_> { + builder::VpcRouterDelete::new(self) + } + + ///List routes + /// + ///List the routes associated with a router in a particular VPC. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `router_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_router_route_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_list(&self) -> builder::VpcRouterRouteList<'_> { + builder::VpcRouterRouteList::new(self) + } + + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + /// + ///```ignore + /// let response = client.vpc_router_route_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_create(&self) -> builder::VpcRouterRouteCreate<'_> { + builder::VpcRouterRouteCreate::new(self) + } + + ///Fetch a route + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_view(&self) -> builder::VpcRouterRouteView<'_> { + builder::VpcRouterRouteView::new(self) + } + + ///Update a route + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_update(&self) -> builder::VpcRouterRouteUpdate<'_> { + builder::VpcRouterRouteUpdate::new(self) + } + + ///Delete a route + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_router_route_delete(&self) -> builder::VpcRouterRouteDelete<'_> { + builder::VpcRouterRouteDelete::new(self) + } + + ///List subnets + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_subnet_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_list(&self) -> builder::VpcSubnetList<'_> { + builder::VpcSubnetList::new(self) + } + + ///Create a subnet + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + /// + ///```ignore + /// let response = client.vpc_subnet_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_create(&self) -> builder::VpcSubnetCreate<'_> { + builder::VpcSubnetCreate::new(self) + } + + ///Fetch a subnet + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_view(&self) -> builder::VpcSubnetView<'_> { + builder::VpcSubnetView::new(self) + } + + ///Update a subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_update(&self) -> builder::VpcSubnetUpdate<'_> { + builder::VpcSubnetUpdate::new(self) + } + + ///Delete a subnet + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_delete(&self) -> builder::VpcSubnetDelete<'_> { + builder::VpcSubnetDelete::new(self) + } + + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `subnet_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_subnet_list_network_interfaces() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnet_list_network_interfaces( + &self, + ) -> builder::VpcSubnetListNetworkInterfaces<'_> { + builder::VpcSubnetListNetworkInterfaces::new(self) + } + + ///Fetch the current silo's IAM policy + /// + ///Sends a `GET` request to `/policy` + /// + ///```ignore + /// let response = client.policy_view() + /// .send() + /// .await; + /// ``` + pub fn policy_view(&self) -> builder::PolicyView<'_> { + builder::PolicyView::new(self) + } + + ///Update the current silo's IAM policy + /// + ///Sends a `PUT` request to `/policy` + /// + ///```ignore + /// let response = client.policy_update() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn policy_update(&self) -> builder::PolicyUpdate<'_> { + builder::PolicyUpdate::new(self) + } + + ///List built-in roles + /// + ///Sends a `GET` request to `/roles` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.role_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn role_list(&self) -> builder::RoleList<'_> { + builder::RoleList::new(self) + } + + ///Fetch a built-in role + /// + ///Sends a `GET` request to `/roles/{role_name}` + /// + ///Arguments: + /// - `role_name`: The built-in role's unique name. + ///```ignore + /// let response = client.role_view() + /// .role_name(role_name) + /// .send() + /// .await; + /// ``` + pub fn role_view(&self) -> builder::RoleView<'_> { + builder::RoleView::new(self) + } + + ///Fetch the user associated with the current session + /// + ///Sends a `GET` request to `/session/me` + /// + ///```ignore + /// let response = client.session_me() + /// .send() + /// .await; + /// ``` + pub fn session_me(&self) -> builder::SessionMe<'_> { + builder::SessionMe::new(self) + } + + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_me_groups() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn session_me_groups(&self) -> builder::SessionMeGroups<'_> { + builder::SessionMeGroups::new(self) + } + + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. + /// + ///Sends a `GET` request to `/session/me/sshkeys` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_sshkey_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn session_sshkey_list(&self) -> builder::SessionSshkeyList<'_> { + builder::SessionSshkeyList::new(self) + } + + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. + /// + ///Sends a `POST` request to `/session/me/sshkeys` + /// + ///```ignore + /// let response = client.session_sshkey_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn session_sshkey_create(&self) -> builder::SessionSshkeyCreate<'_> { + builder::SessionSshkeyCreate::new(self) + } + + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + /// + ///```ignore + /// let response = client.session_sshkey_view() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + pub fn session_sshkey_view(&self) -> builder::SessionSshkeyView<'_> { + builder::SessionSshkeyView::new(self) + } + + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + /// + ///```ignore + /// let response = client.session_sshkey_delete() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + pub fn session_sshkey_delete(&self) -> builder::SessionSshkeyDelete<'_> { + builder::SessionSshkeyDelete::new(self) + } + + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + /// + ///```ignore + /// let response = client.system_image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn system_image_view_by_id(&self) -> builder::SystemImageViewById<'_> { + builder::SystemImageViewById::new(self) + } + + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + /// + ///```ignore + /// let response = client.ip_pool_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById<'_> { + builder::IpPoolViewById::new(self) + } + + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + /// + ///```ignore + /// let response = client.silo_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn silo_view_by_id(&self) -> builder::SiloViewById<'_> { + builder::SiloViewById::new(self) + } + + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.certificate_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn certificate_list(&self) -> builder::CertificateList<'_> { + builder::CertificateList::new(self) + } + + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + /// + ///```ignore + /// let response = client.certificate_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn certificate_create(&self) -> builder::CertificateCreate<'_> { + builder::CertificateCreate::new(self) + } + + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_view() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + pub fn certificate_view(&self) -> builder::CertificateView<'_> { + builder::CertificateView::new(self) + } + + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_delete() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + pub fn certificate_delete(&self) -> builder::CertificateDelete<'_> { + builder::CertificateDelete::new(self) + } + + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.physical_disk_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn physical_disk_list(&self) -> builder::PhysicalDiskList<'_> { + builder::PhysicalDiskList::new(self) + } + + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.rack_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn rack_list(&self) -> builder::RackList<'_> { + builder::RackList::new(self) + } + + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + ///```ignore + /// let response = client.rack_view() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + pub fn rack_view(&self) -> builder::RackView<'_> { + builder::RackView::new(self) + } + + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sled_list(&self) -> builder::SledList<'_> { + builder::SledList::new(self) + } + + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + ///```ignore + /// let response = client.sled_view() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + pub fn sled_view(&self) -> builder::SledView<'_> { + builder::SledView::new(self) + } + + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_physical_disk_list() + /// .sled_id(sled_id) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList<'_> { + builder::SledPhysicalDiskList::new(self) + } + + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_image_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_image_list(&self) -> builder::SystemImageList<'_> { + builder::SystemImageList::new(self) + } + + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + /// + ///```ignore + /// let response = client.system_image_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_image_create(&self) -> builder::SystemImageCreate<'_> { + builder::SystemImageCreate::new(self) + } + + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_view() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn system_image_view(&self) -> builder::SystemImageView<'_> { + builder::SystemImageView::new(self) + } + + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_delete() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn system_image_delete(&self) -> builder::SystemImageDelete<'_> { + builder::SystemImageDelete::new(self) + } + + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.ip_pool_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_list(&self) -> builder::IpPoolList<'_> { + builder::IpPoolList::new(self) + } + + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + /// + ///```ignore + /// let response = client.ip_pool_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_create(&self) -> builder::IpPoolCreate<'_> { + builder::IpPoolCreate::new(self) + } + + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_view() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_view(&self) -> builder::IpPoolView<'_> { + builder::IpPoolView::new(self) + } + + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_update() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_update(&self) -> builder::IpPoolUpdate<'_> { + builder::IpPoolUpdate::new(self) + } + + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_delete() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_delete(&self) -> builder::IpPoolDelete<'_> { + builder::IpPoolDelete::new(self) + } + + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_range_list() + /// .pool_name(pool_name) + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_list(&self) -> builder::IpPoolRangeList<'_> { + builder::IpPoolRangeList::new(self) + } + + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_range_add() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd<'_> { + builder::IpPoolRangeAdd::new(self) + } + + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_range_remove() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove<'_> { + builder::IpPoolRangeRemove::new(self) + } + + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + /// + ///```ignore + /// let response = client.ip_pool_service_view() + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_view(&self) -> builder::IpPoolServiceView<'_> { + builder::IpPoolServiceView::new(self) + } + + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_service_range_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList<'_> { + builder::IpPoolServiceRangeList::new(self) + } + + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_service_range_add() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd<'_> { + builder::IpPoolServiceRangeAdd::new(self) + } + + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_service_range_remove() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove<'_> { + builder::IpPoolServiceRangeRemove::new(self) + } + + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.system_metric() + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .id(id) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + pub fn system_metric(&self) -> builder::SystemMetric<'_> { + builder::SystemMetric::new(self) + } + + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_view() + /// .send() + /// .await; + /// ``` + pub fn system_policy_view(&self) -> builder::SystemPolicyView<'_> { + builder::SystemPolicyView::new(self) + } + + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_update() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_policy_update(&self) -> builder::SystemPolicyUpdate<'_> { + builder::SystemPolicyUpdate::new(self) + } + + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.saga_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn saga_list(&self) -> builder::SagaList<'_> { + builder::SagaList::new(self) + } + + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + /// + ///```ignore + /// let response = client.saga_view() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + pub fn saga_view(&self) -> builder::SagaView<'_> { + builder::SagaView::new(self) + } + + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn silo_list(&self) -> builder::SiloList<'_> { + builder::SiloList::new(self) + } + + ///Create a silo + /// + ///Sends a `POST` request to `/system/silos` + /// + ///```ignore + /// let response = client.silo_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn silo_create(&self) -> builder::SiloCreate<'_> { + builder::SiloCreate::new(self) + } + + ///Fetch a silo + /// + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silo_view(&self) -> builder::SiloView<'_> { + builder::SiloView::new(self) + } + + ///Delete a silo + /// + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_delete() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silo_delete(&self) -> builder::SiloDelete<'_> { + builder::SiloDelete::new(self) + } + + ///List a silo's IDPs + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_identity_provider_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList<'_> { + builder::SiloIdentityProviderList::new(self) + } + + ///Create a user + /// + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.local_idp_user_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate<'_> { + builder::LocalIdpUserCreate::new(self) + } + + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.local_idp_user_delete() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete<'_> { + builder::LocalIdpUserDelete::new(self) + } + + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + ///```ignore + /// let response = client.local_idp_user_set_password() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword<'_> { + builder::LocalIdpUserSetPassword::new(self) + } + + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.saml_identity_provider_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate<'_> { + builder::SamlIdentityProviderCreate::new(self) + } + + ///Fetch a SAML IDP + /// + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `provider_name`: The SAML identity provider's name + ///```ignore + /// let response = client.saml_identity_provider_view() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + pub fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView<'_> { + builder::SamlIdentityProviderView::new(self) + } + + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_policy_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silo_policy_view(&self) -> builder::SiloPolicyView<'_> { + builder::SiloPolicyView::new(self) + } + + ///Update a silo's IAM policy + /// + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.silo_policy_update() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn silo_policy_update(&self) -> builder::SiloPolicyUpdate<'_> { + builder::SiloPolicyUpdate::new(self) + } + + ///List users in a silo + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_users_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn silo_users_list(&self) -> builder::SiloUsersList<'_> { + builder::SiloUsersList::new(self) + } + + ///Fetch a user + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.silo_user_view() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + pub fn silo_user_view(&self) -> builder::SiloUserView<'_> { + builder::SiloUserView::new(self) + } + + ///List built-in users + /// + ///Sends a `GET` request to `/system/user` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_user_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_user_list(&self) -> builder::SystemUserList<'_> { + builder::SystemUserList::new(self) + } + + ///Fetch a built-in user + /// + ///Sends a `GET` request to `/system/user/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. + ///```ignore + /// let response = client.system_user_view() + /// .user_name(user_name) + /// .send() + /// .await; + /// ``` + pub fn system_user_view(&self) -> builder::SystemUserView<'_> { + builder::SystemUserView::new(self) + } + + ///List timeseries schema + /// + ///Sends a `GET` request to `/timeseries/schema` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.timeseries_schema_get() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn timeseries_schema_get(&self) -> builder::TimeseriesSchemaGet<'_> { + builder::TimeseriesSchemaGet::new(self) + } + + ///List users + /// + ///Sends a `GET` request to `/users` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.user_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn user_list(&self) -> builder::UserList<'_> { + builder::UserList::new(self) + } + + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.disk_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn disk_list_v1(&self) -> builder::DiskListV1<'_> { + builder::DiskListV1::new(self) + } + + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + /// + ///```ignore + /// let response = client.disk_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn disk_create_v1(&self) -> builder::DiskCreateV1<'_> { + builder::DiskCreateV1::new(self) + } + + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_view_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn disk_view_v1(&self) -> builder::DiskViewV1<'_> { + builder::DiskViewV1::new(self) + } + + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_delete_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn disk_delete_v1(&self) -> builder::DiskDeleteV1<'_> { + builder::DiskDeleteV1::new(self) + } + + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_list_v1(&self) -> builder::InstanceListV1<'_> { + builder::InstanceListV1::new(self) + } + + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + /// + ///```ignore + /// let response = client.instance_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_create_v1(&self) -> builder::InstanceCreateV1<'_> { + builder::InstanceCreateV1::new(self) + } + + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_view_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_view_v1(&self) -> builder::InstanceViewV1<'_> { + builder::InstanceViewV1::new(self) + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_delete_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_delete_v1(&self) -> builder::InstanceDeleteV1<'_> { + builder::InstanceDeleteV1::new(self) + } + + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list_v1() + /// .instance(instance) + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1<'_> { + builder::InstanceDiskListV1::new(self) + } + + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1<'_> { + builder::InstanceDiskAttachV1::new(self) + } + + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1<'_> { + builder::InstanceDiskDetachV1::new(self) + } + + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1<'_> { + builder::InstanceMigrateV1::new(self) + } + + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_reboot_v1(&self) -> builder::InstanceRebootV1<'_> { + builder::InstanceRebootV1::new(self) + } + + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + ///```ignore + /// let response = client.instance_serial_console_v1() + /// .instance(instance) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1<'_> { + builder::InstanceSerialConsoleV1::new(self) + } + + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1<'_> { + builder::InstanceSerialConsoleStreamV1::new(self) + } + + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + /// + ///```ignore + /// let response = client.instance_start_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_start_v1(&self) -> builder::InstanceStartV1<'_> { + builder::InstanceStartV1::new(self) + } + + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + /// + ///```ignore + /// let response = client.instance_stop_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + pub fn instance_stop_v1(&self) -> builder::InstanceStopV1<'_> { + builder::InstanceStopV1::new(self) + } + + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list_v1() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn organization_list_v1(&self) -> builder::OrganizationListV1<'_> { + builder::OrganizationListV1::new(self) + } + + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + /// + ///```ignore + /// let response = client.organization_create_v1() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_create_v1(&self) -> builder::OrganizationCreateV1<'_> { + builder::OrganizationCreateV1::new(self) + } + + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_view_v1(&self) -> builder::OrganizationViewV1<'_> { + builder::OrganizationViewV1::new(self) + } + + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_update_v1(&self) -> builder::OrganizationUpdateV1<'_> { + builder::OrganizationUpdateV1::new(self) + } + + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_delete_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1<'_> { + builder::OrganizationDeleteV1::new(self) + } + + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1<'_> { + builder::OrganizationPolicyViewV1::new(self) + } + + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1<'_> { + builder::OrganizationPolicyUpdateV1::new(self) + } + + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_list_v1(&self) -> builder::ProjectListV1<'_> { + builder::ProjectListV1::new(self) + } + + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + /// + ///```ignore + /// let response = client.project_create_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_create_v1(&self) -> builder::ProjectCreateV1<'_> { + builder::ProjectCreateV1::new(self) + } + + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_view_v1(&self) -> builder::ProjectViewV1<'_> { + builder::ProjectViewV1::new(self) + } + + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_update_v1(&self) -> builder::ProjectUpdateV1<'_> { + builder::ProjectUpdateV1::new(self) + } + + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_delete_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_delete_v1(&self) -> builder::ProjectDeleteV1<'_> { + builder::ProjectDeleteV1::new(self) + } + + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + pub fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1<'_> { + builder::ProjectPolicyViewV1::new(self) + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1<'_> { + builder::ProjectPolicyUpdateV1::new(self) + } + + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_component_version_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_component_version_list(&self) -> builder::SystemComponentVersionList<'_> { + builder::SystemComponentVersionList::new(self) + } + + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.update_deployments_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn update_deployments_list(&self) -> builder::UpdateDeploymentsList<'_> { + builder::UpdateDeploymentsList::new(self) + } + + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + /// + ///```ignore + /// let response = client.update_deployment_view() + /// .id(id) + /// .send() + /// .await; + /// ``` + pub fn update_deployment_view(&self) -> builder::UpdateDeploymentView<'_> { + builder::UpdateDeploymentView::new(self) + } + + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + /// + ///```ignore + /// let response = client.system_update_refresh() + /// .send() + /// .await; + /// ``` + pub fn system_update_refresh(&self) -> builder::SystemUpdateRefresh<'_> { + builder::SystemUpdateRefresh::new(self) + } + + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + /// + ///```ignore + /// let response = client.system_update_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn system_update_start(&self) -> builder::SystemUpdateStart<'_> { + builder::SystemUpdateStart::new(self) + } + + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + /// + ///```ignore + /// let response = client.system_update_stop() + /// .send() + /// .await; + /// ``` + pub fn system_update_stop(&self) -> builder::SystemUpdateStop<'_> { + builder::SystemUpdateStop::new(self) + } + + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_update_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn system_update_list(&self) -> builder::SystemUpdateList<'_> { + builder::SystemUpdateList::new(self) + } + + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + /// + ///```ignore + /// let response = client.system_update_view() + /// .version(version) + /// .send() + /// .await; + /// ``` + pub fn system_update_view(&self) -> builder::SystemUpdateView<'_> { + builder::SystemUpdateView::new(self) + } + + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + /// + ///```ignore + /// let response = client.system_update_components_list() + /// .version(version) + /// .send() + /// .await; + /// ``` + pub fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList<'_> { + builder::SystemUpdateComponentsList::new(self) + } + + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + /// + ///```ignore + /// let response = client.system_version() + /// .send() + /// .await; + /// ``` + pub fn system_version(&self) -> builder::SystemVersion<'_> { + builder::SystemVersion::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::disk_view_by_id`] + /// + ///[`Client::disk_view_by_id`]: super::Client::disk_view_by_id + #[derive(Debug, Clone)] + pub struct DiskViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> DiskViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/disks/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/disks/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::image_view_by_id`] + /// + ///[`Client::image_view_by_id`]: super::Client::image_view_by_id + #[derive(Debug, Clone)] + pub struct ImageViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> ImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_view_by_id`] + /// + ///[`Client::instance_view_by_id`]: super::Client::instance_view_by_id + #[derive(Debug, Clone)] + pub struct InstanceViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/instances/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/instances/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_network_interface_view_by_id`] + /// + ///[`Client::instance_network_interface_view_by_id`]: super::Client::instance_network_interface_view_by_id + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceNetworkInterfaceViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/network-interfaces/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/network-interfaces/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_view_by_id`] + /// + ///[`Client::organization_view_by_id`]: super::Client::organization_view_by_id + #[derive(Debug, Clone)] + pub struct OrganizationViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> OrganizationViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/organizations/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/organizations/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_view_by_id`] + /// + ///[`Client::project_view_by_id`]: super::Client::project_view_by_id + #[derive(Debug, Clone)] + pub struct ProjectViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> ProjectViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/projects/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/projects/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::snapshot_view_by_id`] + /// + ///[`Client::snapshot_view_by_id`]: super::Client::snapshot_view_by_id + #[derive(Debug, Clone)] + pub struct SnapshotViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SnapshotViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/snapshots/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/snapshots/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_route_view_by_id`] + /// + ///[`Client::vpc_router_route_view_by_id`]: super::Client::vpc_router_route_view_by_id + #[derive(Debug, Clone)] + pub struct VpcRouterRouteViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcRouterRouteViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-router-routes/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_view_by_id`] + /// + ///[`Client::vpc_router_view_by_id`]: super::Client::vpc_router_view_by_id + #[derive(Debug, Clone)] + pub struct VpcRouterViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcRouterViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-routers/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-routers/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_view_by_id`] + /// + ///[`Client::vpc_subnet_view_by_id`]: super::Client::vpc_subnet_view_by_id + #[derive(Debug, Clone)] + pub struct VpcSubnetViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcSubnetViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-subnets/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_view_by_id`] + /// + ///[`Client::vpc_view_by_id`]: super::Client::vpc_view_by_id + #[derive(Debug, Clone)] + pub struct VpcViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpcs/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpcs/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::device_auth_request`] + /// + ///[`Client::device_auth_request`]: super::Client::device_auth_request + #[derive(Debug, Clone)] + pub struct DeviceAuthRequest<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAuthRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DeviceAuthRequest` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthRequest, + ) -> types::builder::DeviceAuthRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/auth` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::DeviceAuthRequest::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/auth", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_auth_request", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`Client::device_auth_confirm`] + /// + ///[`Client::device_auth_confirm`]: super::Client::device_auth_confirm + #[derive(Debug, Clone)] + pub struct DeviceAuthConfirm<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAuthConfirm<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DeviceAuthVerify` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthVerify, + ) -> types::builder::DeviceAuthVerify, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/confirm` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::DeviceAuthVerify::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/confirm", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "device_auth_confirm", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::device_access_token`] + /// + ///[`Client::device_access_token`]: super::Client::device_access_token + #[derive(Debug, Clone)] + pub struct DeviceAccessToken<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAccessToken<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `DeviceAccessTokenRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAccessTokenRequest, + ) -> types::builder::DeviceAccessTokenRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/token` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::DeviceAccessTokenRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/token", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_access_token", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`Client::group_list`] + /// + ///[`Client::group_list`]: super::Client::group_list + #[derive(Debug, Clone)] + pub struct GroupList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> GroupList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/groups` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/groups", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "group_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/groups` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::login_spoof`] + /// + ///[`Client::login_spoof`]: super::Client::login_spoof + #[derive(Debug, Clone)] + pub struct LoginSpoof<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> LoginSpoof<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SpoofLoginBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SpoofLoginBody) -> types::builder::SpoofLoginBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/login` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SpoofLoginBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/login", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_spoof", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::login_local`] + /// + ///[`Client::login_local`]: super::Client::login_local + #[derive(Debug, Clone)] + pub struct LoginLocal<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LoginLocal<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `UsernamePasswordCredentials` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::UsernamePasswordCredentials, + ) -> types::builder::UsernamePasswordCredentials, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::UsernamePasswordCredentials::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/local", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_local", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::login_saml_begin`] + /// + ///[`Client::login_saml_begin`]: super::Client::login_saml_begin + #[derive(Debug, Clone)] + pub struct LoginSamlBegin<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> LoginSamlBegin<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "login_saml_begin", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::login_saml`] + /// + ///[`Client::login_saml`]: super::Client::login_saml + #[derive(Debug)] + pub struct LoginSaml<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> LoginSaml<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto<::wasm_bindgen::JsValue>, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `wasm_bindgen::JsValue` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "login_saml", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::logout`] + /// + ///[`Client::logout`]: super::Client::logout + #[derive(Debug, Clone)] + pub struct Logout<'a> { + client: &'a super::Client, + } + + impl<'a> Logout<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/logout` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/logout", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "logout", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_list`] + /// + ///[`Client::organization_list`]: super::Client::organization_list + #[derive(Debug, Clone)] + pub struct OrganizationList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::organization_create`] + /// + ///[`Client::organization_create`]: super::Client::organization_create + #[derive(Debug, Clone)] + pub struct OrganizationCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::OrganizationCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_view`] + /// + ///[`Client::organization_view`]: super::Client::organization_view + #[derive(Debug, Clone)] + pub struct OrganizationView<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_update`] + /// + ///[`Client::organization_update`]: super::Client::organization_update + #[derive(Debug, Clone)] + pub struct OrganizationUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> OrganizationUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_delete`] + /// + ///[`Client::organization_delete`]: super::Client::organization_delete + #[derive(Debug, Clone)] + pub struct OrganizationDelete<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_view`] + /// + ///[`Client::organization_policy_view`]: super::Client::organization_policy_view + #[derive(Debug, Clone)] + pub struct OrganizationPolicyView<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_update`] + /// + ///[`Client::organization_policy_update`]: super::Client::organization_policy_update + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_list`] + /// + ///[`Client::project_list`]: super::Client::project_list + #[derive(Debug, Clone)] + pub struct ProjectList<'a> { + client: &'a super::Client, + organization_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::project_create`] + /// + ///[`Client::project_create`]: super::Client::project_create + #[derive(Debug, Clone)] + pub struct ProjectCreate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> ProjectCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_view`] + /// + ///[`Client::project_view`]: super::Client::project_view + #[derive(Debug, Clone)] + pub struct ProjectView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_update`] + /// + ///[`Client::project_update`]: super::Client::project_update + #[derive(Debug, Clone)] + pub struct ProjectUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ProjectUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_delete`] + /// + ///[`Client::project_delete`]: super::Client::project_delete + #[derive(Debug, Clone)] + pub struct ProjectDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_list`] + /// + ///[`Client::disk_list`]: super::Client::disk_list + #[derive(Debug, Clone)] + pub struct DiskList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::disk_create`] + /// + ///[`Client::disk_create`]: super::Client::disk_create + #[derive(Debug, Clone)] + pub struct DiskCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> DiskCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_view`] + /// + ///[`Client::disk_view`]: super::Client::disk_view + #[derive(Debug, Clone)] + pub struct DiskView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + } + + impl<'a> DiskView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_delete`] + /// + ///[`Client::disk_delete`]: super::Client::disk_delete + #[derive(Debug, Clone)] + pub struct DiskDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + } + + impl<'a> DiskDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_metrics_list`] + /// + ///[`Client::disk_metrics_list`]: super::Client::disk_metrics_list + #[derive(Debug, Clone)] + pub struct DiskMetricsList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + metric_name: Result, + end_time: Result>, String>, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> DiskMetricsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `DiskMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.end_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end_time \ + failed" + .to_string() + }); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.start_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for \ + start_time failed" + .to_string() + }); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + metric_name, + end_time, + limit, + page_token, + start_time, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}/metrics/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_metrics_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + end_time: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::image_list`] + /// + ///[`Client::image_list`]: super::Client::image_list + #[derive(Debug, Clone)] + pub struct ImageList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::image_create`] + /// + ///[`Client::image_create`]: super::Client::image_create + #[derive(Debug, Clone)] + pub struct ImageCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ImageCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ImageCreate) -> types::builder::ImageCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ImageCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "image_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::image_view`] + /// + ///[`Client::image_view`]: super::Client::image_view + #[derive(Debug, Clone)] + pub struct ImageView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + image_name: Result, + } + + impl<'a> ImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + image_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::image_delete`] + /// + ///[`Client::image_delete`]: super::Client::image_delete + #[derive(Debug, Clone)] + pub struct ImageDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + image_name: Result, + } + + impl<'a> ImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + image_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_list`] + /// + ///[`Client::instance_list`]: super::Client::instance_list + #[derive(Debug, Clone)] + pub struct InstanceList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::instance_create`] + /// + ///[`Client::instance_create`]: super::Client::instance_create + #[derive(Debug, Clone)] + pub struct InstanceCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> InstanceCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_view`] + /// + ///[`Client::instance_view`]: super::Client::instance_view + #[derive(Debug, Clone)] + pub struct InstanceView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_delete`] + /// + ///[`Client::instance_delete`]: super::Client::instance_delete + #[derive(Debug, Clone)] + pub struct InstanceDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_list`] + /// + ///[`Client::instance_disk_list`]: super::Client::instance_disk_list + #[derive(Debug, Clone)] + pub struct InstanceDiskList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::instance_disk_attach`] + /// + ///[`Client::instance_disk_attach`]: super::Client::instance_disk_attach + #[derive(Debug, Clone)] + pub struct InstanceDiskAttach<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceDiskAttach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskIdentifier::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/attach", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_detach`] + /// + ///[`Client::instance_disk_detach`]: super::Client::instance_disk_detach + #[derive(Debug, Clone)] + pub struct InstanceDiskDetach<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceDiskDetach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskIdentifier::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/detach", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_external_ip_list`] + /// + ///[`Client::instance_external_ip_list`]: super::Client::instance_external_ip_list + #[derive(Debug, Clone)] + pub struct InstanceExternalIpList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceExternalIpList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/external-ips` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/external-ips", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_external_ip_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_migrate`] + /// + ///[`Client::instance_migrate`]: super::Client::instance_migrate + #[derive(Debug, Clone)] + pub struct InstanceMigrate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceMigrate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceMigrate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/migrate", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_network_interface_list`] + /// + ///[`Client::instance_network_interface_list`]: super::Client::instance_network_interface_list + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceNetworkInterfaceList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + organization_name, + project_name, + instance_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::instance_network_interface_create`] + /// + ///[`Client::instance_network_interface_create`]: super::Client::instance_network_interface_create + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceNetworkInterfaceCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceCreate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceCreate, + ) -> types::builder::NetworkInterfaceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::NetworkInterfaceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_network_interface_view`] + /// + ///[`Client::instance_network_interface_view`]: super::Client::instance_network_interface_view + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + } + + impl<'a> InstanceNetworkInterfaceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_network_interface_update`] + /// + ///[`Client::instance_network_interface_update`]: super::Client::instance_network_interface_update + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + body: Result, + } + + impl<'a> InstanceNetworkInterfaceUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceUpdate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceUpdate, + ) -> types::builder::NetworkInterfaceUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::NetworkInterfaceUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_network_interface_delete`] + /// + ///[`Client::instance_network_interface_delete`]: super::Client::instance_network_interface_delete + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + } + + impl<'a> InstanceNetworkInterfaceDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_reboot`] + /// + ///[`Client::instance_reboot`]: super::Client::instance_reboot + #[derive(Debug, Clone)] + pub struct InstanceReboot<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceReboot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/reboot", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console`] + /// + ///[`Client::instance_serial_console`]: super::Client::instance_serial_console + #[derive(Debug, Clone)] + pub struct InstanceSerialConsole<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + } + + impl<'a> InstanceSerialConsole<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for most_recent failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + from_start, + max_bytes, + most_recent, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console_stream`] + /// + ///[`Client::instance_serial_console_stream`]: super::Client::instance_serial_console_stream + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStream<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceSerialConsoleStream<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`Client::instance_start`] + /// + ///[`Client::instance_start`]: super::Client::instance_start + #[derive(Debug, Clone)] + pub struct InstanceStart<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/start", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_stop`] + /// + ///[`Client::instance_stop`]: super::Client::instance_stop + #[derive(Debug, Clone)] + pub struct InstanceStop<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/stop", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_view`] + /// + ///[`Client::project_policy_view`]: super::Client::project_policy_view + #[derive(Debug, Clone)] + pub struct ProjectPolicyView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_update`] + /// + ///[`Client::project_policy_update`]: super::Client::project_policy_update + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ProjectPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::snapshot_list`] + /// + ///[`Client::snapshot_list`]: super::Client::snapshot_list + #[derive(Debug, Clone)] + pub struct SnapshotList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SnapshotList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::snapshot_create`] + /// + ///[`Client::snapshot_create`]: super::Client::snapshot_create + #[derive(Debug, Clone)] + pub struct SnapshotCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> SnapshotCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SnapshotCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SnapshotCreate) -> types::builder::SnapshotCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::SnapshotCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "snapshot_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::snapshot_view`] + /// + ///[`Client::snapshot_view`]: super::Client::snapshot_view + #[derive(Debug, Clone)] + pub struct SnapshotView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + snapshot_name: Result, + } + + impl<'a> SnapshotView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + snapshot_name: Err("snapshot_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn snapshot_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.snapshot_name = value + .try_into() + .map_err(|_| "conversion to `Name` for snapshot_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots/{snapshot_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + snapshot_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let snapshot_name = snapshot_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::snapshot_delete`] + /// + ///[`Client::snapshot_delete`]: super::Client::snapshot_delete + #[derive(Debug, Clone)] + pub struct SnapshotDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + snapshot_name: Result, + } + + impl<'a> SnapshotDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + snapshot_name: Err("snapshot_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn snapshot_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.snapshot_name = value + .try_into() + .map_err(|_| "conversion to `Name` for snapshot_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots/{snapshot_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + snapshot_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let snapshot_name = snapshot_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_list`] + /// + ///[`Client::vpc_list`]: super::Client::vpc_list + #[derive(Debug, Clone)] + pub struct VpcList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::vpc_create`] + /// + ///[`Client::vpc_create`]: super::Client::vpc_create + #[derive(Debug, Clone)] + pub struct VpcCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> VpcCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcCreate) -> types::builder::VpcCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_view`] + /// + ///[`Client::vpc_view`]: super::Client::vpc_view + #[derive(Debug, Clone)] + pub struct VpcView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_update`] + /// + ///[`Client::vpc_update`]: super::Client::vpc_update + #[derive(Debug, Clone)] + pub struct VpcUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcUpdate) -> types::builder::VpcUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_delete`] + /// + ///[`Client::vpc_delete`]: super::Client::vpc_delete + #[derive(Debug, Clone)] + pub struct VpcDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_firewall_rules_view`] + /// + ///[`Client::vpc_firewall_rules_view`]: super::Client::vpc_firewall_rules_view + #[derive(Debug, Clone)] + pub struct VpcFirewallRulesView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcFirewallRulesView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_firewall_rules_update`] + /// + ///[`Client::vpc_firewall_rules_update`]: super::Client::vpc_firewall_rules_update + #[derive(Debug, Clone)] + pub struct VpcFirewallRulesUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcFirewallRulesUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `VpcFirewallRuleUpdateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::VpcFirewallRuleUpdateParams, + ) -> types::builder::VpcFirewallRuleUpdateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::VpcFirewallRuleUpdateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_list`] + /// + ///[`Client::vpc_router_list`]: super::Client::vpc_router_list + #[derive(Debug, Clone)] + pub struct VpcRouterList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcRouterList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::vpc_router_create`] + /// + ///[`Client::vpc_router_create`]: super::Client::vpc_router_create + #[derive(Debug, Clone)] + pub struct VpcRouterCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcRouterCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcRouterCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterCreate) -> types::builder::VpcRouterCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcRouterCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_view`] + /// + ///[`Client::vpc_router_view`]: super::Client::vpc_router_view + #[derive(Debug, Clone)] + pub struct VpcRouterView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + } + + impl<'a> VpcRouterView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_update`] + /// + ///[`Client::vpc_router_update`]: super::Client::vpc_router_update + #[derive(Debug, Clone)] + pub struct VpcRouterUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + body: Result, + } + + impl<'a> VpcRouterUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcRouterUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterUpdate) -> types::builder::VpcRouterUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcRouterUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_delete`] + /// + ///[`Client::vpc_router_delete`]: super::Client::vpc_router_delete + #[derive(Debug, Clone)] + pub struct VpcRouterDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + } + + impl<'a> VpcRouterDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_route_list`] + /// + ///[`Client::vpc_router_route_list`]: super::Client::vpc_router_route_list + #[derive(Debug, Clone)] + pub struct VpcRouterRouteList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcRouterRouteList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::vpc_router_route_create`] + /// + ///[`Client::vpc_router_route_create`]: super::Client::vpc_router_route_create + #[derive(Debug, Clone)] + pub struct VpcRouterRouteCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + body: Result, + } + + impl<'a> VpcRouterRouteCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteCreateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteCreateParams, + ) -> types::builder::RouterRouteCreateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::RouterRouteCreateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_route_view`] + /// + ///[`Client::vpc_router_route_view`]: super::Client::vpc_router_route_view + #[derive(Debug, Clone)] + pub struct VpcRouterRouteView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + } + + impl<'a> VpcRouterRouteView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_route_update`] + /// + ///[`Client::vpc_router_route_update`]: super::Client::vpc_router_route_update + #[derive(Debug, Clone)] + pub struct VpcRouterRouteUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + body: Result, + } + + impl<'a> VpcRouterRouteUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteUpdateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteUpdateParams, + ) -> types::builder::RouterRouteUpdateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::RouterRouteUpdateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_router_route_delete`] + /// + ///[`Client::vpc_router_route_delete`]: super::Client::vpc_router_route_delete + #[derive(Debug, Clone)] + pub struct VpcRouterRouteDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + } + + impl<'a> VpcRouterRouteDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_list`] + /// + ///[`Client::vpc_subnet_list`]: super::Client::vpc_subnet_list + #[derive(Debug, Clone)] + pub struct VpcSubnetList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcSubnetList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::vpc_subnet_create`] + /// + ///[`Client::vpc_subnet_create`]: super::Client::vpc_subnet_create + #[derive(Debug, Clone)] + pub struct VpcSubnetCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcSubnetCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcSubnetCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetCreate) -> types::builder::VpcSubnetCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcSubnetCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_view`] + /// + ///[`Client::vpc_subnet_view`]: super::Client::vpc_subnet_view + #[derive(Debug, Clone)] + pub struct VpcSubnetView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + } + + impl<'a> VpcSubnetView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_update`] + /// + ///[`Client::vpc_subnet_update`]: super::Client::vpc_subnet_update + #[derive(Debug, Clone)] + pub struct VpcSubnetUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + body: Result, + } + + impl<'a> VpcSubnetUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcSubnetUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetUpdate) -> types::builder::VpcSubnetUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcSubnetUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_delete`] + /// + ///[`Client::vpc_subnet_delete`]: super::Client::vpc_subnet_delete + #[derive(Debug, Clone)] + pub struct VpcSubnetDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + } + + impl<'a> VpcSubnetDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::vpc_subnet_list_network_interfaces`] + /// + ///[`Client::vpc_subnet_list_network_interfaces`]: super::Client::vpc_subnet_list_network_interfaces + #[derive(Debug, Clone)] + pub struct VpcSubnetListNetworkInterfaces<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcSubnetListNetworkInterfaces<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list_network_interfaces", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::policy_view`] + /// + ///[`Client::policy_view`]: super::Client::policy_view + #[derive(Debug, Clone)] + pub struct PolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> PolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/policy", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::policy_update`] + /// + ///[`Client::policy_update`]: super::Client::policy_update + #[derive(Debug, Clone)] + pub struct PolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> PolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SiloRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/policy", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::role_list`] + /// + ///[`Client::role_list`]: super::Client::role_list + #[derive(Debug, Clone)] + pub struct RoleList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> RoleList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/roles` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/roles", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/roles` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::role_view`] + /// + ///[`Client::role_view`]: super::Client::role_view + #[derive(Debug, Clone)] + pub struct RoleView<'a> { + client: &'a super::Client, + role_name: Result<::std::string::String, String>, + } + + impl<'a> RoleView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + role_name: Err("role_name was not initialized".to_string()), + } + } + + pub fn role_name(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.role_name = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for role_name failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/roles/{role_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, role_name } = self; + let role_name = role_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/roles/{}", + client.baseurl, + encode_path(&role_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::session_me`] + /// + ///[`Client::session_me`]: super::Client::session_me + #[derive(Debug, Clone)] + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/session/me` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/session/me", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::session_me_groups`] + /// + ///[`Client::session_me_groups`]: super::Client::session_me_groups + #[derive(Debug, Clone)] + pub struct SessionMeGroups<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SessionMeGroups<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/groups` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/groups", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me_groups", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/session/me/groups` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::session_sshkey_list`] + /// + ///[`Client::session_sshkey_list`]: super::Client::session_sshkey_list + #[derive(Debug, Clone)] + pub struct SessionSshkeyList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SessionSshkeyList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/sshkeys` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/session/me/sshkeys` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::session_sshkey_create`] + /// + ///[`Client::session_sshkey_create`]: super::Client::session_sshkey_create + #[derive(Debug, Clone)] + pub struct SessionSshkeyCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SessionSshkeyCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SshKeyCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SshKeyCreate) -> types::builder::SshKeyCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/session/me/sshkeys` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SshKeyCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "session_sshkey_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::session_sshkey_view`] + /// + ///[`Client::session_sshkey_view`]: super::Client::session_sshkey_view + #[derive(Debug, Clone)] + pub struct SessionSshkeyView<'a> { + client: &'a super::Client, + ssh_key_name: Result, + } + + impl<'a> SessionSshkeyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + ssh_key_name: Err("ssh_key_name was not initialized".to_string()), + } + } + + pub fn ssh_key_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.ssh_key_name = value + .try_into() + .map_err(|_| "conversion to `Name` for ssh_key_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + ssh_key_name, + } = self; + let ssh_key_name = ssh_key_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::session_sshkey_delete`] + /// + ///[`Client::session_sshkey_delete`]: super::Client::session_sshkey_delete + #[derive(Debug, Clone)] + pub struct SessionSshkeyDelete<'a> { + client: &'a super::Client, + ssh_key_name: Result, + } + + impl<'a> SessionSshkeyDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + ssh_key_name: Err("ssh_key_name was not initialized".to_string()), + } + } + + pub fn ssh_key_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.ssh_key_name = value + .try_into() + .map_err(|_| "conversion to `Name` for ssh_key_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + ssh_key_name, + } = self; + let ssh_key_name = ssh_key_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_image_view_by_id`] + /// + ///[`Client::system_image_view_by_id`]: super::Client::system_image_view_by_id + #[derive(Debug, Clone)] + pub struct SystemImageViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SystemImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_view_by_id`] + /// + ///[`Client::ip_pool_view_by_id`]: super::Client::ip_pool_view_by_id + #[derive(Debug, Clone)] + pub struct IpPoolViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> IpPoolViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/ip-pools/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_view_by_id`] + /// + ///[`Client::silo_view_by_id`]: super::Client::silo_view_by_id + #[derive(Debug, Clone)] + pub struct SiloViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SiloViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/silos/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_list`] + /// + ///[`Client::certificate_list`]: super::Client::certificate_list + #[derive(Debug, Clone)] + pub struct CertificateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> CertificateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/certificates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::certificate_create`] + /// + ///[`Client::certificate_create`]: super::Client::certificate_create + #[derive(Debug, Clone)] + pub struct CertificateCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> CertificateCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `CertificateCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::CertificateCreate, + ) -> types::builder::CertificateCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/certificates` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::CertificateCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "certificate_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_view`] + /// + ///[`Client::certificate_view`]: super::Client::certificate_view + #[derive(Debug, Clone)] + pub struct CertificateView<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::certificate_delete`] + /// + ///[`Client::certificate_delete`]: super::Client::certificate_delete + #[derive(Debug, Clone)] + pub struct CertificateDelete<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::physical_disk_list`] + /// + ///[`Client::physical_disk_list`]: super::Client::physical_disk_list + #[derive(Debug, Clone)] + pub struct PhysicalDiskList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> PhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/disks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "physical_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::rack_list`] + /// + ///[`Client::rack_list`]: super::Client::rack_list + #[derive(Debug, Clone)] + pub struct RackList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> RackList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/racks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::rack_view`] + /// + ///[`Client::rack_view`]: super::Client::rack_view + #[derive(Debug, Clone)] + pub struct RackView<'a> { + client: &'a super::Client, + rack_id: Result<::uuid::Uuid, String>, + } + + impl<'a> RackView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + rack_id: Err("rack_id was not initialized".to_string()), + } + } + + pub fn rack_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.rack_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for rack_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let rack_id = rack_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::sled_list`] + /// + ///[`Client::sled_list`]: super::Client::sled_list + #[derive(Debug, Clone)] + pub struct SledList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/sleds", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::sled_view`] + /// + ///[`Client::sled_view`]: super::Client::sled_view + #[derive(Debug, Clone)] + pub struct SledView<'a> { + client: &'a super::Client, + sled_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SledView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + sled_id: Err("sled_id was not initialized".to_string()), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for sled_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::sled_physical_disk_list`] + /// + ///[`Client::sled_physical_disk_list`]: super::Client::sled_physical_disk_list + #[derive(Debug, Clone)] + pub struct SledPhysicalDiskList<'a> { + client: &'a super::Client, + sled_id: Result<::uuid::Uuid, String>, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledPhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + sled_id: Err("sled_id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for sled_id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + sled_id, + limit, + page_token, + sort_by, + } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}/disks", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_physical_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds/{sled_id}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::system_image_list`] + /// + ///[`Client::system_image_list`]: super::Client::system_image_list + #[derive(Debug, Clone)] + pub struct SystemImageList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::system_image_create`] + /// + ///[`Client::system_image_create`]: super::Client::system_image_create + #[derive(Debug, Clone)] + pub struct SystemImageCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `GlobalImageCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::GlobalImageCreate, + ) -> types::builder::GlobalImageCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::GlobalImageCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_image_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_image_view`] + /// + ///[`Client::system_image_view`]: super::Client::system_image_view + #[derive(Debug, Clone)] + pub struct SystemImageView<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_image_delete`] + /// + ///[`Client::system_image_delete`]: super::Client::system_image_delete + #[derive(Debug, Clone)] + pub struct SystemImageDelete<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_list`] + /// + ///[`Client::ip_pool_list`]: super::Client::ip_pool_list + #[derive(Debug, Clone)] + pub struct IpPoolList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> IpPoolList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::ip_pool_create`] + /// + ///[`Client::ip_pool_create`]: super::Client::ip_pool_create + #[derive(Debug, Clone)] + pub struct IpPoolCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `IpPoolCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolCreate) -> types::builder::IpPoolCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/ip-pools` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::IpPoolCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_view`] + /// + ///[`Client::ip_pool_view`]: super::Client::ip_pool_view + #[derive(Debug, Clone)] + pub struct IpPoolView<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_update`] + /// + ///[`Client::ip_pool_update`]: super::Client::ip_pool_update + #[derive(Debug, Clone)] + pub struct IpPoolUpdate<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `IpPoolUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolUpdate) -> types::builder::IpPoolUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::IpPoolUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_delete`] + /// + ///[`Client::ip_pool_delete`]: super::Client::ip_pool_delete + #[derive(Debug, Clone)] + pub struct IpPoolDelete<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_range_list`] + /// + ///[`Client::ip_pool_range_list`]: super::Client::ip_pool_range_list + #[derive(Debug, Clone)] + pub struct IpPoolRangeList<'a> { + client: &'a super::Client, + pool_name: Result, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + pool_name, + limit, + page_token, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_range_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools/{pool_name}/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::ip_pool_range_add`] + /// + ///[`Client::ip_pool_range_add`]: super::Client::ip_pool_range_add + #[derive(Debug, Clone)] + pub struct IpPoolRangeAdd<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_add", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_range_remove`] + /// + ///[`Client::ip_pool_range_remove`]: super::Client::ip_pool_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolRangeRemove<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_remove", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_view`] + /// + ///[`Client::ip_pool_service_view`]: super::Client::ip_pool_service_view + #[derive(Debug, Clone)] + pub struct IpPoolServiceView<'a> { + client: &'a super::Client, + } + + impl<'a> IpPoolServiceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/ip-pools-service", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_range_list`] + /// + ///[`Client::ip_pool_service_range_list`]: super::Client::ip_pool_service_range_list + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolServiceRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools-service/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::ip_pool_service_range_add`] + /// + ///[`Client::ip_pool_service_range_add`]: super::Client::ip_pool_service_range_add + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeAdd<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/add", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_add", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ip_pool_service_range_remove`] + /// + ///[`Client::ip_pool_service_range_remove`]: super::Client::ip_pool_service_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeRemove<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/remove", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_remove", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_metric`] + /// + ///[`Client::system_metric`]: super::Client::system_metric + #[derive(Debug, Clone)] + pub struct SystemMetric<'a> { + client: &'a super::Client, + metric_name: Result, + end_time: Result>, String>, + id: Result<::uuid::Uuid, String>, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> SystemMetric<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + id: Err("id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `SystemMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.end_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end_time \ + failed" + .to_string() + }); + self + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.start_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for \ + start_time failed" + .to_string() + }); + self + } + + ///Sends a `GET` request to `/system/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + metric_name, + end_time, + id, + limit, + page_token, + start_time, + } = self; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let id = id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/metrics/{}", + client.baseurl, + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_metric", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_policy_view`] + /// + ///[`Client::system_policy_view`]: super::Client::system_policy_view + #[derive(Debug, Clone)] + pub struct SystemPolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> SystemPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/policy", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_policy_update`] + /// + ///[`Client::system_policy_update`]: super::Client::system_policy_update + #[derive(Debug, Clone)] + pub struct SystemPolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `FleetRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FleetRolePolicy) -> types::builder::FleetRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::FleetRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/policy", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saga_list`] + /// + ///[`Client::saga_list`]: super::Client::saga_list + #[derive(Debug, Clone)] + pub struct SagaList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SagaList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/sagas", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::saga_view`] + /// + ///[`Client::saga_view`]: super::Client::saga_view + #[derive(Debug, Clone)] + pub struct SagaView<'a> { + client: &'a super::Client, + saga_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SagaView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + saga_id: Err("saga_id was not initialized".to_string()), + } + } + + pub fn saga_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.saga_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for saga_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let saga_id = saga_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_list`] + /// + ///[`Client::silo_list`]: super::Client::silo_list + #[derive(Debug, Clone)] + pub struct SiloList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/silos", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/silos` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::silo_create`] + /// + ///[`Client::silo_create`]: super::Client::silo_create + #[derive(Debug, Clone)] + pub struct SiloCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SiloCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloCreate) -> types::builder::SiloCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/silos` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SiloCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/silos", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_view`] + /// + ///[`Client::silo_view`]: super::Client::silo_view + #[derive(Debug, Clone)] + pub struct SiloView<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_delete`] + /// + ///[`Client::silo_delete`]: super::Client::silo_delete + #[derive(Debug, Clone)] + pub struct SiloDelete<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_identity_provider_list`] + /// + ///[`Client::silo_identity_provider_list`]: super::Client::silo_identity_provider_list + #[derive(Debug, Clone)] + pub struct SiloIdentityProviderList<'a> { + client: &'a super::Client, + silo_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloIdentityProviderList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + silo_name, + limit, + page_token, + sort_by, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_identity_provider_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::local_idp_user_create`] + /// + ///[`Client::local_idp_user_create`]: super::Client::local_idp_user_create + #[derive(Debug, Clone)] + pub struct LocalIdpUserCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LocalIdpUserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::local_idp_user_delete`] + /// + ///[`Client::local_idp_user_delete`]: super::Client::local_idp_user_delete + #[derive(Debug, Clone)] + pub struct LocalIdpUserDelete<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + } + + impl<'a> LocalIdpUserDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "local_idp_user_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::local_idp_user_set_password`] + /// + ///[`Client::local_idp_user_set_password`]: super::Client::local_idp_user_set_password + #[derive(Debug, Clone)] + pub struct LocalIdpUserSetPassword<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + body: Result, + } + + impl<'a> LocalIdpUserSetPassword<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserPassword` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_set_password", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saml_identity_provider_create`] + /// + ///[`Client::saml_identity_provider_create`]: super::Client::saml_identity_provider_create + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SamlIdentityProviderCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `SamlIdentityProviderCreate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SamlIdentityProviderCreate, + ) -> types::builder::SamlIdentityProviderCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::SamlIdentityProviderCreate::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "saml_identity_provider_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::saml_identity_provider_view`] + /// + ///[`Client::saml_identity_provider_view`]: super::Client::saml_identity_provider_view + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderView<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> SamlIdentityProviderView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saml_identity_provider_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_policy_view`] + /// + ///[`Client::silo_policy_view`]: super::Client::silo_policy_view + #[derive(Debug, Clone)] + pub struct SiloPolicyView<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_policy_update`] + /// + ///[`Client::silo_policy_update`]: super::Client::silo_policy_update + #[derive(Debug, Clone)] + pub struct SiloPolicyUpdate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SiloPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::SiloRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::silo_users_list`] + /// + ///[`Client::silo_users_list`]: super::Client::silo_users_list + #[derive(Debug, Clone)] + pub struct SiloUsersList<'a> { + client: &'a super::Client, + silo_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloUsersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + limit, + page_token, + sort_by, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/users/all", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_users_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/silos/{silo_name}/users/all` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::silo_user_view`] + /// + ///[`Client::silo_user_view`]: super::Client::silo_user_view + #[derive(Debug, Clone)] + pub struct SiloUserView<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SiloUserView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/users/id/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/users/id/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_user_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_user_list`] + /// + ///[`Client::system_user_list`]: super::Client::system_user_list + #[derive(Debug, Clone)] + pub struct SystemUserList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUserList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/user` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/user", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/user` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::system_user_view`] + /// + ///[`Client::system_user_view`]: super::Client::system_user_view + #[derive(Debug, Clone)] + pub struct SystemUserView<'a> { + client: &'a super::Client, + user_name: Result, + } + + impl<'a> SystemUserView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user_name: Err("user_name was not initialized".to_string()), + } + } + + pub fn user_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_name = value + .try_into() + .map_err(|_| "conversion to `Name` for user_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/user/{user_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, user_name } = self; + let user_name = user_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/user/{}", + client.baseurl, + encode_path(&user_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::timeseries_schema_get`] + /// + ///[`Client::timeseries_schema_get`]: super::Client::timeseries_schema_get + #[derive(Debug, Clone)] + pub struct TimeseriesSchemaGet<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> TimeseriesSchemaGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/timeseries/schema` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/timeseries/schema", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "timeseries_schema_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/timeseries/schema` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::user_list`] + /// + ///[`Client::user_list`]: super::Client::user_list + #[derive(Debug, Clone)] + pub struct UserList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UserList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/users", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "user_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/users` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::disk_list_v1`] + /// + ///[`Client::disk_list_v1`]: super::Client::disk_list_v1 + #[derive(Debug, Clone)] + pub struct DiskListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::disk_create_v1`] + /// + ///[`Client::disk_create_v1`]: super::Client::disk_create_v1 + #[derive(Debug, Clone)] + pub struct DiskCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> DiskCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_view_v1`] + /// + ///[`Client::disk_view_v1`]: super::Client::disk_view_v1 + #[derive(Debug, Clone)] + pub struct DiskViewV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::disk_delete_v1`] + /// + ///[`Client::disk_delete_v1`]: super::Client::disk_delete_v1 + #[derive(Debug, Clone)] + pub struct DiskDeleteV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_list_v1`] + /// + ///[`Client::instance_list_v1`]: super::Client::instance_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::instance_create_v1`] + /// + ///[`Client::instance_create_v1`]: super::Client::instance_create_v1 + #[derive(Debug, Clone)] + pub struct InstanceCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> InstanceCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_view_v1`] + /// + ///[`Client::instance_view_v1`]: super::Client::instance_view_v1 + #[derive(Debug, Clone)] + pub struct InstanceViewV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_delete_v1`] + /// + ///[`Client::instance_delete_v1`]: super::Client::instance_delete_v1 + #[derive(Debug, Clone)] + pub struct InstanceDeleteV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_list_v1`] + /// + ///[`Client::instance_disk_list_v1`]: super::Client::instance_disk_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskListV1<'a> { + client: &'a super::Client, + instance: Result, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances/{instance}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::instance_disk_attach_v1`] + /// + ///[`Client::instance_disk_attach_v1`]: super::Client::instance_disk_attach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskAttachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskAttachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskPath::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/attach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_disk_detach_v1`] + /// + ///[`Client::instance_disk_detach_v1`]: super::Client::instance_disk_detach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskDetachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskDetachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskPath::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/detach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_migrate_v1`] + /// + ///[`Client::instance_migrate_v1`]: super::Client::instance_migrate_v1 + #[derive(Debug, Clone)] + pub struct InstanceMigrateV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceMigrateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceMigrate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/migrate", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_reboot_v1`] + /// + ///[`Client::instance_reboot_v1`]: super::Client::instance_reboot_v1 + #[derive(Debug, Clone)] + pub struct InstanceRebootV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceRebootV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/reboot", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console_v1`] + /// + ///[`Client::instance_serial_console_v1`]: super::Client::instance_serial_console_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleV1<'a> { + client: &'a super::Client, + instance: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for most_recent failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + from_start, + max_bytes, + most_recent, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial_console_stream_v1`] + /// + ///[`Client::instance_serial_console_stream_v1`]: super::Client::instance_serial_console_stream_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStreamV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleStreamV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&instance.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`Client::instance_start_v1`] + /// + ///[`Client::instance_start_v1`]: super::Client::instance_start_v1 + #[derive(Debug, Clone)] + pub struct InstanceStartV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStartV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/start", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_stop_v1`] + /// + ///[`Client::instance_stop_v1`]: super::Client::instance_stop_v1 + #[derive(Debug, Clone)] + pub struct InstanceStopV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStopV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/stop", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_list_v1`] + /// + ///[`Client::organization_list_v1`]: super::Client::organization_list_v1 + #[derive(Debug, Clone)] + pub struct OrganizationListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::organization_create_v1`] + /// + ///[`Client::organization_create_v1`]: super::Client::organization_create_v1 + #[derive(Debug, Clone)] + pub struct OrganizationCreateV1<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::OrganizationCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_view_v1`] + /// + ///[`Client::organization_view_v1`]: super::Client::organization_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_update_v1`] + /// + ///[`Client::organization_update_v1`]: super::Client::organization_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_delete_v1`] + /// + ///[`Client::organization_delete_v1`]: super::Client::organization_delete_v1 + #[derive(Debug, Clone)] + pub struct OrganizationDeleteV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_view_v1`] + /// + ///[`Client::organization_policy_view_v1`]: super::Client::organization_policy_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::organization_policy_update_v1`] + /// + ///[`Client::organization_policy_update_v1`]: super::Client::organization_policy_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_list_v1`] + /// + ///[`Client::project_list_v1`]: super::Client::project_list_v1 + #[derive(Debug, Clone)] + pub struct ProjectListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::project_create_v1`] + /// + ///[`Client::project_create_v1`]: super::Client::project_create_v1 + #[derive(Debug, Clone)] + pub struct ProjectCreateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> ProjectCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_view_v1`] + /// + ///[`Client::project_view_v1`]: super::Client::project_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_update_v1`] + /// + ///[`Client::project_update_v1`]: super::Client::project_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_delete_v1`] + /// + ///[`Client::project_delete_v1`]: super::Client::project_delete_v1 + #[derive(Debug, Clone)] + pub struct ProjectDeleteV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_view_v1`] + /// + ///[`Client::project_policy_view_v1`]: super::Client::project_policy_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::project_policy_update_v1`] + /// + ///[`Client::project_policy_update_v1`]: super::Client::project_policy_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_component_version_list`] + /// + ///[`Client::system_component_version_list`]: super::Client::system_component_version_list + #[derive(Debug, Clone)] + pub struct SystemComponentVersionList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemComponentVersionList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/components` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/components", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_component_version_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/components` + pub fn stream( + self, + ) -> impl futures::Stream>> + + Unpin + + 'a { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::update_deployments_list`] + /// + ///[`Client::update_deployments_list`]: super::Client::update_deployments_list + #[derive(Debug, Clone)] + pub struct UpdateDeploymentsList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UpdateDeploymentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/deployments", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployments_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/deployments` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::update_deployment_view`] + /// + ///[`Client::update_deployment_view`]: super::Client::update_deployment_view + #[derive(Debug, Clone)] + pub struct UpdateDeploymentView<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> UpdateDeploymentView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/deployments/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployment_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_refresh`] + /// + ///[`Client::system_update_refresh`]: super::Client::system_update_refresh + #[derive(Debug, Clone)] + pub struct SystemUpdateRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/refresh", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_refresh", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_start`] + /// + ///[`Client::system_update_start`]: super::Client::system_update_start + #[derive(Debug, Clone)] + pub struct SystemUpdateStart<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemUpdateStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SystemUpdateStart` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SystemUpdateStart, + ) -> types::builder::SystemUpdateStart, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SystemUpdateStart::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/start", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_update_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_stop`] + /// + ///[`Client::system_update_stop`]: super::Client::system_update_stop + #[derive(Debug, Clone)] + pub struct SystemUpdateStop<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/stop", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_stop", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_list`] + /// + ///[`Client::system_update_list`]: super::Client::system_update_list + #[derive(Debug, Clone)] + pub struct SystemUpdateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUpdateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/updates", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/updates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`Client::system_update_view`] + /// + ///[`Client::system_update_view`]: super::Client::system_update_view + #[derive(Debug, Clone)] + pub struct SystemUpdateView<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn send(self) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_update_components_list`] + /// + ///[`Client::system_update_components_list`]: super::Client::system_update_components_list + #[derive(Debug, Clone)] + pub struct SystemUpdateComponentsList<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateComponentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}/components", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_components_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::system_version`] + /// + ///[`Client::system_version`]: super::Client::system_version + #[derive(Debug, Clone)] + pub struct SystemVersion<'a> { + client: &'a super::Client, + } + + impl<'a> SystemVersion<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/version", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_version", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/nexus_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/nexus_builder_tagged.rs new file mode 100644 index 00000000..9007149a --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/nexus_builder_tagged.rs @@ -0,0 +1,50471 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///Describes properties that should uniquely identify a Gimlet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes properties that should uniquely identify a + /// Gimlet.", + /// "type": "object", + /// "required": [ + /// "part", + /// "revision", + /// "serial" + /// ], + /// "properties": { + /// "part": { + /// "type": "string" + /// }, + /// "revision": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "serial": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Baseboard { + pub part: ::std::string::String, + pub revision: i64, + pub serial: ::std::string::String, + } + + impl ::std::convert::From<&Baseboard> for Baseboard { + fn from(value: &Baseboard) -> Self { + value.clone() + } + } + + impl Baseboard { + pub fn builder() -> builder::Baseboard { + Default::default() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum BinRangedouble { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: f64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: f64, start: f64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: f64 }, + } + + impl ::std::convert::From<&Self> for BinRangedouble { + fn from(value: &BinRangedouble) -> Self { + value.clone() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum BinRangeint64 { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: i64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: i64, start: i64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: i64 }, + } + + impl ::std::convert::From<&Self> for BinRangeint64 { + fn from(value: &BinRangeint64) -> Self { + value.clone() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangedouble" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Bindouble { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangedouble, + } + + impl ::std::convert::From<&Bindouble> for Bindouble { + fn from(value: &Bindouble) -> Self { + value.clone() + } + } + + impl Bindouble { + pub fn builder() -> builder::Bindouble { + Default::default() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangeint64" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Binint64 { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangeint64, + } + + impl ::std::convert::From<&Binint64> for Binint64 { + fn from(value: &Binint64) -> Self { + value.clone() + } + } + + impl Binint64 { + pub fn builder() -> builder::Binint64 { + Default::default() + } + } + + ///`BlockSize` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "disk block size in bytes", + /// "type": "integer", + /// "enum": [ + /// 512, + /// 2048, + /// 4096 + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct BlockSize(i64); + impl ::std::ops::Deref for BlockSize { + type Target = i64; + fn deref(&self) -> &i64 { + &self.0 + } + } + + impl ::std::convert::From for i64 { + fn from(value: BlockSize) -> Self { + value.0 + } + } + + impl ::std::convert::From<&BlockSize> for BlockSize { + fn from(value: &BlockSize) -> Self { + value.clone() + } + } + + impl ::std::convert::TryFrom for BlockSize { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> ::std::result::Result { + if ![512_i64, 2048_i64, 4096_i64].contains(&value) { + Err("invalid value".into()) + } else { + Ok(Self(value)) + } + } + } + + impl<'de> ::serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + Self::try_from(::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + + ///A count of bytes, typically used either for memory or storage capacity + /// + ///The maximum supported byte count is [`i64::MAX`]. This makes it + /// somewhat inconvenient to define constructors: a u32 constructor can be + /// infallible, but an i64 constructor can fail (if the value is negative) + /// and a u64 constructor can fail (if the value is larger than i64::MAX). + /// We provide all of these for consumers' convenience. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A count of bytes, typically used either for memory or + /// storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. + /// This makes it somewhat inconvenient to define constructors: a u32 + /// constructor can be infallible, but an i64 constructor can fail (if the + /// value is negative) and a u64 constructor can fail (if the value is + /// larger than i64::MAX). We provide all of these for consumers' + /// convenience.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct ByteCount(pub u64); + impl ::std::ops::Deref for ByteCount { + type Target = u64; + fn deref(&self) -> &u64 { + &self.0 + } + } + + impl ::std::convert::From for u64 { + fn from(value: ByteCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&ByteCount> for ByteCount { + fn from(value: &ByteCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for ByteCount { + fn from(value: u64) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for ByteCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for ByteCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for ByteCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for ByteCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for ByteCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of a [`Certificate`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Certificate`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "service", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "service": { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Certificate> for Certificate { + fn from(value: &Certificate) -> Self { + value.clone() + } + } + + impl Certificate { + pub fn builder() -> builder::Certificate { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate)", + /// "type": "object", + /// "required": [ + /// "cert", + /// "description", + /// "key", + /// "name", + /// "service" + /// ], + /// "properties": { + /// "cert": { + /// "description": "PEM file containing public certificate chain", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "key": { + /// "description": "PEM file containing private key", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "service": { + /// "description": "The service using this certificate", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: ::std::vec::Vec, + pub description: ::std::string::String, + ///PEM file containing private key + pub key: ::std::vec::Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + impl ::std::convert::From<&CertificateCreate> for CertificateCreate { + fn from(value: &CertificateCreate) -> Self { + value.clone() + } + } + + impl CertificateCreate { + pub fn builder() -> builder::CertificateCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Certificate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&CertificateResultsPage> for CertificateResultsPage { + fn from(value: &CertificateResultsPage) -> Self { + value.clone() + } + } + + impl CertificateResultsPage { + pub fn builder() -> builder::CertificateResultsPage { + Default::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&ComponentUpdate> for ComponentUpdate { + fn from(value: &ComponentUpdate) -> Self { + value.clone() + } + } + + impl ComponentUpdate { + pub fn builder() -> builder::ComponentUpdate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ComponentUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ComponentUpdateResultsPage> for ComponentUpdateResultsPage { + fn from(value: &ComponentUpdateResultsPage) -> Self { + value.clone() + } + } + + impl ComponentUpdateResultsPage { + pub fn builder() -> builder::ComponentUpdateResultsPage { + Default::default() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "number", + /// "format": "double" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Cumulativedouble { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: f64, + } + + impl ::std::convert::From<&Cumulativedouble> for Cumulativedouble { + fn from(value: &Cumulativedouble) -> Self { + value.clone() + } + } + + impl Cumulativedouble { + pub fn builder() -> builder::Cumulativedouble { + Default::default() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Cumulativeint64 { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: i64, + } + + impl ::std::convert::From<&Cumulativeint64> for Cumulativeint64 { + fn from(value: &Cumulativeint64) -> Self { + value.clone() + } + } + + impl Cumulativeint64 { + pub fn builder() -> builder::Cumulativeint64 { + Default::default() + } + } + + ///A `Datum` is a single sampled data point from a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Datum` is a single sampled data point from a + /// metric.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "boolean" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bool" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "string" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bytes" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativeint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativedouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramdouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_f64" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "datum")] + pub enum Datum { + #[serde(rename = "bool")] + Bool(bool), + #[serde(rename = "i64")] + I64(i64), + #[serde(rename = "f64")] + F64(f64), + #[serde(rename = "string")] + String(::std::string::String), + #[serde(rename = "bytes")] + Bytes(::std::vec::Vec), + #[serde(rename = "cumulative_i64")] + CumulativeI64(Cumulativeint64), + #[serde(rename = "cumulative_f64")] + CumulativeF64(Cumulativedouble), + #[serde(rename = "histogram_i64")] + HistogramI64(Histogramint64), + #[serde(rename = "histogram_f64")] + HistogramF64(Histogramdouble), + } + + impl ::std::convert::From<&Self> for Datum { + fn from(value: &Datum) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Datum { + fn from(value: bool) -> Self { + Self::Bool(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: i64) -> Self { + Self::I64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: f64) -> Self { + Self::F64(value) + } + } + + impl ::std::convert::From<::std::vec::Vec> for Datum { + fn from(value: ::std::vec::Vec) -> Self { + Self::Bytes(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativeint64) -> Self { + Self::CumulativeI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativedouble) -> Self { + Self::CumulativeF64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramint64) -> Self { + Self::HistogramI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramdouble) -> Self { + Self::HistogramF64(value) + } + } + + ///The type of an individual datum of a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The type of an individual datum of a metric.", + /// "type": "string", + /// "enum": [ + /// "bool", + /// "i64", + /// "f64", + /// "string", + /// "bytes", + /// "cumulative_i64", + /// "cumulative_f64", + /// "histogram_i64", + /// "histogram_f64" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum DatumType { + #[serde(rename = "bool")] + Bool, + #[serde(rename = "i64")] + I64, + #[serde(rename = "f64")] + F64, + #[serde(rename = "string")] + String, + #[serde(rename = "bytes")] + Bytes, + #[serde(rename = "cumulative_i64")] + CumulativeI64, + #[serde(rename = "cumulative_f64")] + CumulativeF64, + #[serde(rename = "histogram_i64")] + HistogramI64, + #[serde(rename = "histogram_f64")] + HistogramF64, + } + + impl ::std::convert::From<&Self> for DatumType { + fn from(value: &DatumType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DatumType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Bool => f.write_str("bool"), + Self::I64 => f.write_str("i64"), + Self::F64 => f.write_str("f64"), + Self::String => f.write_str("string"), + Self::Bytes => f.write_str("bytes"), + Self::CumulativeI64 => f.write_str("cumulative_i64"), + Self::CumulativeF64 => f.write_str("cumulative_f64"), + Self::HistogramI64 => f.write_str("histogram_i64"), + Self::HistogramF64 => f.write_str("histogram_f64"), + } + } + } + + impl ::std::str::FromStr for DatumType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bool" => Ok(Self::Bool), + "i64" => Ok(Self::I64), + "f64" => Ok(Self::F64), + "string" => Ok(Self::String), + "bytes" => Ok(Self::Bytes), + "cumulative_i64" => Ok(Self::CumulativeI64), + "cumulative_f64" => Ok(Self::CumulativeF64), + "histogram_i64" => Ok(Self::HistogramI64), + "histogram_f64" => Ok(Self::HistogramF64), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DatumType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DerEncodedKeyPair` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "private_key", + /// "public_cert" + /// ], + /// "properties": { + /// "private_key": { + /// "description": "request signing private key (base64 encoded der + /// file)", + /// "type": "string" + /// }, + /// "public_cert": { + /// "description": "request signing public certificate (base64 encoded + /// der file)", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DerEncodedKeyPair { + ///request signing private key (base64 encoded der file) + pub private_key: ::std::string::String, + ///request signing public certificate (base64 encoded der file) + pub public_cert: ::std::string::String, + } + + impl ::std::convert::From<&DerEncodedKeyPair> for DerEncodedKeyPair { + fn from(value: &DerEncodedKeyPair) -> Self { + value.clone() + } + } + + impl DerEncodedKeyPair { + pub fn builder() -> builder::DerEncodedKeyPair { + Default::default() + } + } + + ///`DeviceAccessTokenRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id", + /// "device_code", + /// "grant_type" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "device_code": { + /// "type": "string" + /// }, + /// "grant_type": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAccessTokenRequest { + pub client_id: ::uuid::Uuid, + pub device_code: ::std::string::String, + pub grant_type: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAccessTokenRequest> for DeviceAccessTokenRequest { + fn from(value: &DeviceAccessTokenRequest) -> Self { + value.clone() + } + } + + impl DeviceAccessTokenRequest { + pub fn builder() -> builder::DeviceAccessTokenRequest { + Default::default() + } + } + + ///`DeviceAuthRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAuthRequest { + pub client_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&DeviceAuthRequest> for DeviceAuthRequest { + fn from(value: &DeviceAuthRequest) -> Self { + value.clone() + } + } + + impl DeviceAuthRequest { + pub fn builder() -> builder::DeviceAuthRequest { + Default::default() + } + } + + ///`DeviceAuthVerify` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "user_code" + /// ], + /// "properties": { + /// "user_code": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAuthVerify { + pub user_code: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAuthVerify> for DeviceAuthVerify { + fn from(value: &DeviceAuthVerify) -> Self { + value.clone() + } + } + + impl DeviceAuthVerify { + pub fn builder() -> builder::DeviceAuthVerify { + Default::default() + } + } + + ///`Digest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "sha256" + /// ] + /// }, + /// "value": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum Digest { + #[serde(rename = "sha256")] + Sha256(::std::string::String), + } + + impl ::std::convert::From<&Self> for Digest { + fn from(value: &Digest) -> Self { + value.clone() + } + } + + ///Client view of a [`Disk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Disk`]", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "device_path", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "device_path": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "snapshot_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Disk { + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub device_path: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub image_id: ::std::option::Option<::uuid::Uuid>, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub snapshot_id: ::std::option::Option<::uuid::Uuid>, + pub state: DiskState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Disk> for Disk { + fn from(value: &Disk) -> Self { + value.clone() + } + } + + impl Disk { + pub fn builder() -> builder::Disk { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskCreate { + pub description: ::std::string::String, + ///initial source for this disk + pub disk_source: DiskSource, + pub name: Name, + ///total size of the Disk in bytes + pub size: ByteCount, + } + + impl ::std::convert::From<&DiskCreate> for DiskCreate { + fn from(value: &DiskCreate) -> Self { + value.clone() + } + } + + impl DiskCreate { + pub fn builder() -> builder::DiskCreate { + Default::default() + } + } + + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance", + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskIdentifier { + pub name: Name, + } + + impl ::std::convert::From<&DiskIdentifier> for DiskIdentifier { + fn from(value: &DiskIdentifier) -> Self { + value.clone() + } + } + + impl DiskIdentifier { + pub fn builder() -> builder::DiskIdentifier { + Default::default() + } + } + + ///`DiskMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "activated", + /// "flush", + /// "read", + /// "read_bytes", + /// "write", + /// "write_bytes" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum DiskMetricName { + #[serde(rename = "activated")] + Activated, + #[serde(rename = "flush")] + Flush, + #[serde(rename = "read")] + Read, + #[serde(rename = "read_bytes")] + ReadBytes, + #[serde(rename = "write")] + Write, + #[serde(rename = "write_bytes")] + WriteBytes, + } + + impl ::std::convert::From<&Self> for DiskMetricName { + fn from(value: &DiskMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DiskMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Activated => f.write_str("activated"), + Self::Flush => f.write_str("flush"), + Self::Read => f.write_str("read"), + Self::ReadBytes => f.write_str("read_bytes"), + Self::Write => f.write_str("write"), + Self::WriteBytes => f.write_str("write_bytes"), + } + } + } + + impl ::std::str::FromStr for DiskMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "activated" => Ok(Self::Activated), + "flush" => Ok(Self::Flush), + "read" => Ok(Self::Read), + "read_bytes" => Ok(Self::ReadBytes), + "write" => Ok(Self::Write), + "write_bytes" => Ok(Self::WriteBytes), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DiskPath` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk" + /// ], + /// "properties": { + /// "disk": { + /// "$ref": "#/components/schemas/NameOrId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskPath { + pub disk: NameOrId, + } + + impl ::std::convert::From<&DiskPath> for DiskPath { + fn from(value: &DiskPath) -> Self { + value.clone() + } + } + + impl DiskPath { + pub fn builder() -> builder::DiskPath { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Disk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&DiskResultsPage> for DiskResultsPage { + fn from(value: &DiskResultsPage) -> Self { + value.clone() + } + } + + impl DiskResultsPage { + pub fn builder() -> builder::DiskResultsPage { + Default::default() + } + } + + ///Different sources for a disk + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Different sources for a disk", + /// "oneOf": [ + /// { + /// "description": "Create a blank disk", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks for this Disk. valid values are: + /// 512, 2048, or 4096", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "blank" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a disk snapshot", + /// "type": "object", + /// "required": [ + /// "snapshot_id", + /// "type" + /// ], + /// "properties": { + /// "snapshot_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a project image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "image" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a global image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "global_image" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum DiskSource { + ///Create a blank disk + #[serde(rename = "blank")] + Blank { + ///size of blocks for this Disk. valid values are: 512, 2048, or + /// 4096 + block_size: BlockSize, + }, + ///Create a disk from a disk snapshot + #[serde(rename = "snapshot")] + Snapshot { snapshot_id: ::uuid::Uuid }, + ///Create a disk from a project image + #[serde(rename = "image")] + Image { image_id: ::uuid::Uuid }, + ///Create a disk from a global image + #[serde(rename = "global_image")] + GlobalImage { image_id: ::uuid::Uuid }, + } + + impl ::std::convert::From<&Self> for DiskSource { + fn from(value: &DiskSource) -> Self { + value.clone() + } + } + + ///State of a Disk (primarily: attached or not) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "State of a Disk (primarily: attached or not)", + /// "oneOf": [ + /// { + /// "description": "Disk is being initialized", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is ready but detached from any Instance", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being detached from the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk has been destroyed", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is unavailable", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "faulted" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "state", content = "instance")] + pub enum DiskState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "detached")] + Detached, + ///Disk is being attached to the given Instance + #[serde(rename = "attaching")] + Attaching(::uuid::Uuid), + ///Disk is attached to the given Instance + #[serde(rename = "attached")] + Attached(::uuid::Uuid), + ///Disk is being detached from the given Instance + #[serde(rename = "detaching")] + Detaching(::uuid::Uuid), + #[serde(rename = "destroyed")] + Destroyed, + #[serde(rename = "faulted")] + Faulted, + } + + impl ::std::convert::From<&Self> for DiskState { + fn from(value: &DiskState) -> Self { + value.clone() + } + } + + ///OS image distribution + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "OS image distribution", + /// "type": "object", + /// "required": [ + /// "name", + /// "version" + /// ], + /// "properties": { + /// "name": { + /// "description": "The name of the distribution (e.g. \"alpine\" or + /// \"ubuntu\")", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "version": { + /// "description": "The version of the distribution (e.g. \"3.10\" or + /// \"18.04\")", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Distribution { + ///The name of the distribution (e.g. "alpine" or "ubuntu") + pub name: Name, + ///The version of the distribution (e.g. "3.10" or "18.04") + pub version: ::std::string::String, + } + + impl ::std::convert::From<&Distribution> for Distribution { + fn from(value: &Distribution) -> Self { + value.clone() + } + } + + impl Distribution { + pub fn builder() -> builder::Distribution { + Default::default() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + impl Error { + pub fn builder() -> builder::Error { + Default::default() + } + } + + ///`ExternalIp` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "ip", + /// "kind" + /// ], + /// "properties": { + /// "ip": { + /// "type": "string", + /// "format": "ip" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/IpKind" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ExternalIp { + pub ip: ::std::net::IpAddr, + pub kind: IpKind, + } + + impl ::std::convert::From<&ExternalIp> for ExternalIp { + fn from(value: &ExternalIp) -> Self { + value.clone() + } + } + + impl ExternalIp { + pub fn builder() -> builder::ExternalIp { + Default::default() + } + } + + ///Parameters for creating an external IP address for instances. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for creating an external IP address for + /// instances.", + /// "oneOf": [ + /// { + /// "description": "An IP address providing both inbound and outbound + /// access. The address is automatically-assigned from the provided IP Pool, + /// or all available pools if not specified.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "pool_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ephemeral" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum ExternalIpCreate { + ///An IP address providing both inbound and outbound access. The + /// address is automatically-assigned from the provided IP Pool, or all + /// available pools if not specified. + #[serde(rename = "ephemeral")] + Ephemeral { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pool_name: ::std::option::Option, + }, + } + + impl ::std::convert::From<&Self> for ExternalIpCreate { + fn from(value: &ExternalIpCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIp" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ExternalIpResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ExternalIpResultsPage> for ExternalIpResultsPage { + fn from(value: &ExternalIpResultsPage) -> Self { + value.clone() + } + } + + impl ExternalIpResultsPage { + pub fn builder() -> builder::ExternalIpResultsPage { + Default::default() + } + } + + ///The name and type information for a field of a timeseries schema. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The name and type information for a field of a + /// timeseries schema.", + /// "type": "object", + /// "required": [ + /// "name", + /// "source", + /// "ty" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "source": { + /// "$ref": "#/components/schemas/FieldSource" + /// }, + /// "ty": { + /// "$ref": "#/components/schemas/FieldType" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FieldSchema { + pub name: ::std::string::String, + pub source: FieldSource, + pub ty: FieldType, + } + + impl ::std::convert::From<&FieldSchema> for FieldSchema { + fn from(value: &FieldSchema) -> Self { + value.clone() + } + } + + impl FieldSchema { + pub fn builder() -> builder::FieldSchema { + Default::default() + } + } + + ///The source from which a field is derived, the target or metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source from which a field is derived, the target or + /// metric.", + /// "type": "string", + /// "enum": [ + /// "target", + /// "metric" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FieldSource { + #[serde(rename = "target")] + Target, + #[serde(rename = "metric")] + Metric, + } + + impl ::std::convert::From<&Self> for FieldSource { + fn from(value: &FieldSource) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Target => f.write_str("target"), + Self::Metric => f.write_str("metric"), + } + } + } + + impl ::std::str::FromStr for FieldSource { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "target" => Ok(Self::Target), + "metric" => Ok(Self::Metric), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldSource { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The `FieldType` identifies the data type of a target or metric field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `FieldType` identifies the data type of a target or + /// metric field.", + /// "type": "string", + /// "enum": [ + /// "string", + /// "i64", + /// "ip_addr", + /// "uuid", + /// "bool" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FieldType { + #[serde(rename = "string")] + String, + #[serde(rename = "i64")] + I64, + #[serde(rename = "ip_addr")] + IpAddr, + #[serde(rename = "uuid")] + Uuid, + #[serde(rename = "bool")] + Bool, + } + + impl ::std::convert::From<&Self> for FieldType { + fn from(value: &FieldType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::String => f.write_str("string"), + Self::I64 => f.write_str("i64"), + Self::IpAddr => f.write_str("ip_addr"), + Self::Uuid => f.write_str("uuid"), + Self::Bool => f.write_str("bool"), + } + } + } + + impl ::std::str::FromStr for FieldType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "string" => Ok(Self::String), + "i64" => Ok(Self::I64), + "ip_addr" => Ok(Self::IpAddr), + "uuid" => Ok(Self::Uuid), + "bool" => Ok(Self::Bool), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`FleetRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FleetRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for FleetRole { + fn from(value: &FleetRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FleetRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for FleetRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FleetRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FleetRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FleetRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&FleetRolePolicy> for FleetRolePolicy { + fn from(value: &FleetRolePolicy) -> Self { + value.clone() + } + } + + impl FleetRolePolicy { + pub fn builder() -> builder::FleetRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/FleetRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FleetRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: FleetRole, + } + + impl ::std::convert::From<&FleetRoleRoleAssignment> for FleetRoleRoleAssignment { + fn from(value: &FleetRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl FleetRoleRoleAssignment { + pub fn builder() -> builder::FleetRoleRoleAssignment { + Default::default() + } + } + + ///Client view of global Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of global Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "id", + /// "name", + /// "size", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "distribution": { + /// "description": "Image distribution", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Image version", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImage { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///Image distribution + pub distribution: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Image version + pub version: ::std::string::String, + } + + impl ::std::convert::From<&GlobalImage> for GlobalImage { + fn from(value: &GlobalImage) -> Self { + value.clone() + } + } + + impl GlobalImage { + pub fn builder() -> builder::GlobalImage { + Default::default() + } + } + + ///Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "distribution": { + /// "description": "OS image distribution", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Distribution" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + ///OS image distribution + pub distribution: Distribution, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&GlobalImageCreate> for GlobalImageCreate { + fn from(value: &GlobalImageCreate) -> Self { + value.clone() + } + } + + impl GlobalImageCreate { + pub fn builder() -> builder::GlobalImageCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/GlobalImage" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GlobalImageResultsPage> for GlobalImageResultsPage { + fn from(value: &GlobalImageResultsPage) -> Self { + value.clone() + } + } + + impl GlobalImageResultsPage { + pub fn builder() -> builder::GlobalImageResultsPage { + Default::default() + } + } + + ///Client view of a [`Group`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Group`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the group", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this group belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&Group> for Group { + fn from(value: &Group) -> Self { + value.clone() + } + } + + impl Group { + pub fn builder() -> builder::Group { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Group" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GroupResultsPage> for GroupResultsPage { + fn from(value: &GroupResultsPage) -> Self { + value.clone() + } + } + + impl GroupResultsPage { + pub fn builder() -> builder::GroupResultsPage { + Default::default() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Bindouble" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Histogramdouble { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramdouble> for Histogramdouble { + fn from(value: &Histogramdouble) -> Self { + value.clone() + } + } + + impl Histogramdouble { + pub fn builder() -> builder::Histogramdouble { + Default::default() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Binint64" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Histogramint64 { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramint64> for Histogramint64 { + fn from(value: &Histogramint64) -> Self { + value.clone() + } + } + + impl Histogramint64 { + pub fn builder() -> builder::Histogramint64 { + Default::default() + } + } + + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by id + /// only.\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdSortMode { + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for IdSortMode { + fn from(value: &IdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for IdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of an [`IdentityProvider`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`IdentityProvider`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "provider_type", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "provider_type": { + /// "description": "Identity provider type", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdentityProviderType" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IdentityProvider { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///Identity provider type + pub provider_type: IdentityProviderType, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IdentityProvider> for IdentityProvider { + fn from(value: &IdentityProvider) -> Self { + value.clone() + } + } + + impl IdentityProvider { + pub fn builder() -> builder::IdentityProvider { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IdentityProvider" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IdentityProviderResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IdentityProviderResultsPage> for IdentityProviderResultsPage { + fn from(value: &IdentityProviderResultsPage) -> Self { + value.clone() + } + } + + impl IdentityProviderResultsPage { + pub fn builder() -> builder::IdentityProviderResultsPage { + Default::default() + } + } + + ///`IdentityProviderType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "description": "SAML identity provider", + /// "type": "string", + /// "enum": [ + /// "saml" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdentityProviderType { + ///SAML identity provider + #[serde(rename = "saml")] + Saml, + } + + impl ::std::convert::From<&Self> for IdentityProviderType { + fn from(value: &IdentityProviderType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityProviderType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Saml => f.write_str("saml"), + } + } + } + + impl ::std::str::FromStr for IdentityProviderType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml" => Ok(Self::Saml), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Describes what kind of identity is described by an id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes what kind of identity is described by an id", + /// "type": "string", + /// "enum": [ + /// "silo_user", + /// "silo_group" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdentityType { + #[serde(rename = "silo_user")] + SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, + } + + impl ::std::convert::From<&Self> for IdentityType { + fn from(value: &IdentityType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SiloUser => f.write_str("silo_user"), + Self::SiloGroup => f.write_str("silo_group"), + } + } + } + + impl ::std::str::FromStr for IdentityType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IdpMetadataSource` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "data", + /// "type" + /// ], + /// "properties": { + /// "data": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "base64_encoded_xml" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum IdpMetadataSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "base64_encoded_xml")] + Base64EncodedXml { data: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for IdpMetadataSource { + fn from(value: &IdpMetadataSource) -> Self { + value.clone() + } + } + + ///Client view of project Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of project Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "The project the disk belongs to", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Version of this, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Image { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///The project the disk belongs to + pub project_id: ::uuid::Uuid, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Version of this, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub version: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&Image> for Image { + fn from(value: &Image) -> Self { + value.clone() + } + } + + impl Image { + pub fn builder() -> builder::Image { + Default::default() + } + } + + ///Create-time parameters for an + /// [`Image`](crate::external_api::views::Image) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Image`](crate::external_api::views::Image)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&ImageCreate> for ImageCreate { + fn from(value: &ImageCreate) -> Self { + value.clone() + } + } + + impl ImageCreate { + pub fn builder() -> builder::ImageCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Image" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ImageResultsPage> for ImageResultsPage { + fn from(value: &ImageResultsPage) -> Self { + value.clone() + } + } + + impl ImageResultsPage { + pub fn builder() -> builder::ImageResultsPage { + Default::default() + } + } + + ///The source of the underlying image. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source of the underlying image.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "id", + /// "type" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Boot the Alpine ISO that ships with the Propolis + /// zone. Intended for development purposes only.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "you_can_boot_anything_as_long_as_its_alpine" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum ImageSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "snapshot")] + Snapshot { id: ::uuid::Uuid }, + #[serde(rename = "you_can_boot_anything_as_long_as_its_alpine")] + YouCanBootAnythingAsLongAsItsAlpine, + } + + impl ::std::convert::From<&Self> for ImageSource { + fn from(value: &ImageSource) -> Self { + value.clone() + } + } + + ///Client view of an [`Instance`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Instance`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "id", + /// "memory", + /// "name", + /// "ncpus", + /// "project_id", + /// "run_state", + /// "time_created", + /// "time_modified", + /// "time_run_state_updated" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "hostname": { + /// "description": "RFC1035-compliant hostname for the Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "memory allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "ncpus": { + /// "description": "number of CPUs allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this Instance", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "run_state": { + /// "$ref": "#/components/schemas/InstanceState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_run_state_updated": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Instance { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///RFC1035-compliant hostname for the Instance. + pub hostname: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///memory allocated for this Instance + pub memory: ByteCount, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///number of CPUs allocated for this Instance + pub ncpus: InstanceCpuCount, + ///id for the project containing this Instance + pub project_id: ::uuid::Uuid, + pub run_state: InstanceState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub time_run_state_updated: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + impl Instance { + pub fn builder() -> builder::Instance { + Default::default() + } + } + + ///The number of CPUs in an Instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The number of CPUs in an Instance", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct InstanceCpuCount(pub u16); + impl ::std::ops::Deref for InstanceCpuCount { + type Target = u16; + fn deref(&self) -> &u16 { + &self.0 + } + } + + impl ::std::convert::From for u16 { + fn from(value: InstanceCpuCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&InstanceCpuCount> for InstanceCpuCount { + fn from(value: &InstanceCpuCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for InstanceCpuCount { + fn from(value: u16) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for InstanceCpuCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for InstanceCpuCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "memory", + /// "name", + /// "ncpus" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disks": { + /// "description": "The disks to be created or attached for this + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/InstanceDiskAttachment" + /// } + /// }, + /// "external_ips": { + /// "description": "The external IP addresses provided to this + /// instance.\n\nBy default, all instances have outbound connectivity, but + /// no inbound connectivity. These external addresses can be used to provide + /// a fixed, known IP address for making inbound connections to the + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIpCreate" + /// } + /// }, + /// "hostname": { + /// "type": "string" + /// }, + /// "memory": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ncpus": { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// }, + /// "network_interfaces": { + /// "description": "The network interfaces to be created for this + /// instance.", + /// "default": { + /// "type": "default" + /// }, + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceNetworkInterfaceAttachment" + /// } + /// ] + /// }, + /// "start": { + /// "description": "Should this instance be started upon creation; true + /// by default.", + /// "default": true, + /// "type": "boolean" + /// }, + /// "user_data": { + /// "description": "User data for instance initialization systems (such + /// as cloud-init). Must be a Base64-encoded string, as specified in RFC + /// 4648 § 4 (+ and / characters with padding). Maximum 32 KiB unencoded + /// data.", + /// "default": "", + /// "type": "string", + /// "format": "byte" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceCreate { + pub description: ::std::string::String, + ///The disks to be created or attached for this instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + ///The external IP addresses provided to this instance. + /// + ///By default, all instances have outbound connectivity, but no inbound + /// connectivity. These external addresses can be used to provide a + /// fixed, known IP address for making inbound connections to the + /// instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub external_ips: ::std::vec::Vec, + pub hostname: ::std::string::String, + pub memory: ByteCount, + pub name: Name, + pub ncpus: InstanceCpuCount, + ///The network interfaces to be created for this instance. + #[serde(default = "defaults::instance_create_network_interfaces")] + pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, + ///User data for instance initialization systems (such as cloud-init). + /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and + /// / characters with padding). Maximum 32 KiB unencoded data. + #[serde(default)] + pub user_data: ::std::string::String, + } + + impl ::std::convert::From<&InstanceCreate> for InstanceCreate { + fn from(value: &InstanceCreate) -> Self { + value.clone() + } + } + + impl InstanceCreate { + pub fn builder() -> builder::InstanceCreate { + Default::default() + } + } + + ///Describe the instance's disks at creation time + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describe the instance's disks at creation time", + /// "oneOf": [ + /// { + /// "description": "During instance creation, create and attach disks", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size", + /// "type" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "During instance creation, attach this disk", + /// "type": "object", + /// "required": [ + /// "name", + /// "type" + /// ], + /// "properties": { + /// "name": { + /// "description": "A disk name to attach", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "attach" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum InstanceDiskAttachment { + ///During instance creation, create and attach disks + #[serde(rename = "create")] + Create { + description: ::std::string::String, + ///initial source for this disk + disk_source: DiskSource, + name: Name, + ///total size of the Disk in bytes + size: ByteCount, + }, + ///During instance creation, attach this disk + #[serde(rename = "attach")] + Attach { + ///A disk name to attach + name: Name, + }, + } + + impl ::std::convert::From<&Self> for InstanceDiskAttachment { + fn from(value: &InstanceDiskAttachment) -> Self { + value.clone() + } + } + + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "dst_sled_id" + /// ], + /// "properties": { + /// "dst_sled_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrate { + pub dst_sled_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrate> for InstanceMigrate { + fn from(value: &InstanceMigrate) -> Self { + value.clone() + } + } + + impl InstanceMigrate { + pub fn builder() -> builder::InstanceMigrate { + Default::default() + } + } + + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes an attachment of a `NetworkInterface` to an + /// `Instance`, at the time the instance is created.", + /// "oneOf": [ + /// { + /// "description": "Create one or more `NetworkInterface`s for the + /// `Instance`.\n\nIf more than one interface is provided, then the first + /// will be designated the primary interface for the instance.", + /// "type": "object", + /// "required": [ + /// "params", + /// "type" + /// ], + /// "properties": { + /// "params": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceCreate" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "The default networking configuration for an + /// instance is to create a single primary interface with an + /// automatically-assigned IP address. The IP will be pulled from the + /// Project's default VPC / VPC Subnet.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "No network interfaces at all will be created for + /// the instance.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "none" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "params")] + pub enum InstanceNetworkInterfaceAttachment { + ///Create one or more `NetworkInterface`s for the `Instance`. + /// + ///If more than one interface is provided, then the first will be + /// designated the primary interface for the instance. + #[serde(rename = "create")] + Create(::std::vec::Vec), + #[serde(rename = "default")] + Default, + #[serde(rename = "none")] + None, + } + + impl ::std::convert::From<&Self> for InstanceNetworkInterfaceAttachment { + fn from(value: &InstanceNetworkInterfaceAttachment) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec> + for InstanceNetworkInterfaceAttachment + { + fn from(value: ::std::vec::Vec) -> Self { + Self::Create(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&InstanceResultsPage> for InstanceResultsPage { + fn from(value: &InstanceResultsPage) -> Self { + value.clone() + } + } + + impl InstanceResultsPage { + pub fn builder() -> builder::InstanceResultsPage { + Default::default() + } + } + + ///Contents of an Instance's serial console buffer. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Contents of an Instance's serial console buffer.", + /// "type": "object", + /// "required": [ + /// "data", + /// "last_byte_offset" + /// ], + /// "properties": { + /// "data": { + /// "description": "The bytes starting from the requested offset up to + /// either the end of the buffer or the request's `max_bytes`. Provided as a + /// u8 array rather than a string, as it may not be UTF-8.", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "last_byte_offset": { + /// "description": "The absolute offset since boot (suitable for use as + /// `byte_offset` in a subsequent request) of the last byte returned in + /// `data`.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceSerialConsoleData { + ///The bytes starting from the requested offset up to either the end of + /// the buffer or the request's `max_bytes`. Provided as a u8 array + /// rather than a string, as it may not be UTF-8. + pub data: ::std::vec::Vec, + ///The absolute offset since boot (suitable for use as `byte_offset` in + /// a subsequent request) of the last byte returned in `data`. + pub last_byte_offset: u64, + } + + impl ::std::convert::From<&InstanceSerialConsoleData> for InstanceSerialConsoleData { + fn from(value: &InstanceSerialConsoleData) -> Self { + value.clone() + } + } + + impl InstanceSerialConsoleData { + pub fn builder() -> builder::InstanceSerialConsoleData { + Default::default() + } + } + + ///Running state of an Instance (primarily: booted or stopped) + /// + ///This typically reflects whether it's starting, running, stopping, or + /// stopped, but also includes states related to the Instance's lifecycle + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Running state of an Instance (primarily: booted or + /// stopped)\n\nThis typically reflects whether it's starting, running, + /// stopping, or stopped, but also includes states related to the Instance's + /// lifecycle", + /// "oneOf": [ + /// { + /// "description": "The instance is being created.", + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// }, + /// { + /// "description": "The instance is currently starting up.", + /// "type": "string", + /// "enum": [ + /// "starting" + /// ] + /// }, + /// { + /// "description": "The instance is currently running.", + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// }, + /// { + /// "description": "The instance has been requested to stop and a + /// transition to \"Stopped\" is imminent.", + /// "type": "string", + /// "enum": [ + /// "stopping" + /// ] + /// }, + /// { + /// "description": "The instance is currently stopped.", + /// "type": "string", + /// "enum": [ + /// "stopped" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of rebooting - it + /// will remain in the \"rebooting\" state until the VM is starting once + /// more.", + /// "type": "string", + /// "enum": [ + /// "rebooting" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of migrating - it will remain in the \"migrating\" state until the migration process is complete and the destination propolis is ready to continue execution.", + /// "type": "string", + /// "enum": [ + /// "migrating" + /// ] + /// }, + /// { + /// "description": "The instance is attempting to recover from a + /// failure.", + /// "type": "string", + /// "enum": [ + /// "repairing" + /// ] + /// }, + /// { + /// "description": "The instance has encountered a failure.", + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// }, + /// { + /// "description": "The instance has been deleted.", + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceState { + ///The instance is being created. + #[serde(rename = "creating")] + Creating, + ///The instance is currently starting up. + #[serde(rename = "starting")] + Starting, + ///The instance is currently running. + #[serde(rename = "running")] + Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. + #[serde(rename = "stopping")] + Stopping, + ///The instance is currently stopped. + #[serde(rename = "stopped")] + Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. + #[serde(rename = "rebooting")] + Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. + #[serde(rename = "migrating")] + Migrating, + ///The instance is attempting to recover from a failure. + #[serde(rename = "repairing")] + Repairing, + ///The instance has encountered a failure. + #[serde(rename = "failed")] + Failed, + ///The instance has been deleted. + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Starting => f.write_str("starting"), + Self::Running => f.write_str("running"), + Self::Stopping => f.write_str("stopping"), + Self::Stopped => f.write_str("stopped"), + Self::Rebooting => f.write_str("rebooting"), + Self::Migrating => f.write_str("migrating"), + Self::Repairing => f.write_str("repairing"), + Self::Failed => f.write_str("failed"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "starting" => Ok(Self::Starting), + "running" => Ok(Self::Running), + "stopping" => Ok(Self::Stopping), + "stopped" => Ok(Self::Stopped), + "rebooting" => Ok(Self::Rebooting), + "migrating" => Ok(Self::Migrating), + "repairing" => Ok(Self::Repairing), + "failed" => Ok(Self::Failed), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The kind of an external IP address for an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The kind of an external IP address for an instance", + /// "type": "string", + /// "enum": [ + /// "ephemeral", + /// "floating" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IpKind { + #[serde(rename = "ephemeral")] + Ephemeral, + #[serde(rename = "floating")] + Floating, + } + + impl ::std::convert::From<&Self> for IpKind { + fn from(value: &IpKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IpKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Ephemeral => f.write_str("ephemeral"), + Self::Floating => f.write_str("floating"), + } + } + } + + impl ::std::str::FromStr for IpKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "ephemeral" => Ok(Self::Ephemeral), + "floating" => Ok(Self::Floating), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IpKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IpNet` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum IpNet { + V4(Ipv4Net), + V6(Ipv6Net), + } + + impl ::std::convert::From<&Self> for IpNet { + fn from(value: &IpNet) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for IpNet { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::V4(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::V6(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for IpNet { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for IpNet { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::V4(x) => x.fmt(f), + Self::V6(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv4Net) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv6Net) -> Self { + Self::V6(value) + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPool { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPool> for IpPool { + fn from(value: &IpPool) -> Self { + value.clone() + } + } + + impl IpPool { + pub fn builder() -> builder::IpPool { + Default::default() + } + } + + ///Create-time parameters for an IP Pool. + /// + ///See [`IpPool`](crate::external_api::views::IpPool) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an IP Pool.\n\nSee + /// [`IpPool`](crate::external_api::views::IpPool)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&IpPoolCreate> for IpPoolCreate { + fn from(value: &IpPoolCreate) -> Self { + value.clone() + } + } + + impl IpPoolCreate { + pub fn builder() -> builder::IpPoolCreate { + Default::default() + } + } + + ///`IpPoolRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "range", + /// "time_created" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "range": { + /// "$ref": "#/components/schemas/IpRange" + /// }, + /// "time_created": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolRange { + pub id: ::uuid::Uuid, + pub range: IpRange, + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPoolRange> for IpPoolRange { + fn from(value: &IpPoolRange) -> Self { + value.clone() + } + } + + impl IpPoolRange { + pub fn builder() -> builder::IpPoolRange { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPoolRange" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolRangeResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolRangeResultsPage> for IpPoolRangeResultsPage { + fn from(value: &IpPoolRangeResultsPage) -> Self { + value.clone() + } + } + + impl IpPoolRangeResultsPage { + pub fn builder() -> builder::IpPoolRangeResultsPage { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPool" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolResultsPage> for IpPoolResultsPage { + fn from(value: &IpPoolResultsPage) -> Self { + value.clone() + } + } + + impl IpPoolResultsPage { + pub fn builder() -> builder::IpPoolResultsPage { + Default::default() + } + } + + ///Parameters for updating an IP Pool + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating an IP Pool", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&IpPoolUpdate> for IpPoolUpdate { + fn from(value: &IpPoolUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for IpPoolUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl IpPoolUpdate { + pub fn builder() -> builder::IpPoolUpdate { + Default::default() + } + } + + ///`IpRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Range" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Range" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum IpRange { + V4(Ipv4Range), + V6(Ipv6Range), + } + + impl ::std::convert::From<&Self> for IpRange { + fn from(value: &IpRange) -> Self { + value.clone() + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv4Range) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv6Range) -> Self { + Self::V6(value) + } + } + + ///An IPv4 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv4 subnet", + /// "description": "An IPv4 subnet, including prefix and subnet mask", + /// "examples": [ + /// "192.168.1.0/24" + /// ], + /// "type": "string", + /// "pattern": + /// "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\. + /// ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/ + /// ([8-9]|1[0-9]|2[0-9]|3[0-2])$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Ipv4Net(::std::string::String); + impl ::std::ops::Deref for Ipv4Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv4Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv4Net> for Ipv4Net { + fn from(value: &Ipv4Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv4Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv4Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv4 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv4 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv4" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv4" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Ipv4Range { + pub first: ::std::net::Ipv4Addr, + pub last: ::std::net::Ipv4Addr, + } + + impl ::std::convert::From<&Ipv4Range> for Ipv4Range { + fn from(value: &Ipv4Range) -> Self { + value.clone() + } + } + + impl Ipv4Range { + pub fn builder() -> builder::Ipv4Range { + Default::default() + } + } + + ///An IPv6 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv6 subnet", + /// "description": "An IPv6 subnet, including prefix and subnet mask", + /// "examples": [ + /// "fd12:3456::/64" + /// ], + /// "type": "string", + /// "pattern": + /// "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1, + /// 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Ipv6Net(::std::string::String); + impl ::std::ops::Deref for Ipv6Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv6Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv6Net> for Ipv6Net { + fn from(value: &Ipv6Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv6Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv6Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv6 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv6 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv6" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv6" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Ipv6Range { + pub first: ::std::net::Ipv6Addr, + pub last: ::std::net::Ipv6Addr, + } + + impl ::std::convert::From<&Ipv6Range> for Ipv6Range { + fn from(value: &Ipv6Range) -> Self { + value.clone() + } + } + + impl Ipv6Range { + pub fn builder() -> builder::Ipv6Range { + Default::default() + } + } + + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A range of IP ports", + /// "description": "An inclusive-inclusive range of IP ports. The second + /// port may be omitted to represent a single port", + /// "examples": [ + /// "22" + /// ], + /// "type": "string", + /// "maxLength": 11, + /// "minLength": 1, + /// "pattern": "^[0-9]{1,5}(-[0-9]{1,5})?$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct L4PortRange(::std::string::String); + impl ::std::ops::Deref for L4PortRange { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: L4PortRange) -> Self { + value.0 + } + } + + impl ::std::convert::From<&L4PortRange> for L4PortRange { + fn from(value: &L4PortRange) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for L4PortRange { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 11usize { + return Err("longer than 11 characters".into()); + } + if value.chars().count() < 1usize { + return Err("shorter than 1 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for L4PortRange { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A Media Access Control address, in EUI-48 format + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A MAC address", + /// "description": "A Media Access Control address, in EUI-48 format", + /// "examples": [ + /// "ff:ff:ff:ff:ff:ff" + /// ], + /// "type": "string", + /// "maxLength": 17, + /// "minLength": 17, + /// "pattern": "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct MacAddr(::std::string::String); + impl ::std::ops::Deref for MacAddr { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: MacAddr) -> Self { + value.0 + } + } + + impl ::std::convert::From<&MacAddr> for MacAddr { + fn from(value: &MacAddr) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for MacAddr { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 17usize { + return Err("longer than 17 characters".into()); + } + if value.chars().count() < 17usize { + return Err("shorter than 17 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for MacAddr { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for MacAddr { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A `Measurement` is a timestamped datum from a single metric + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Measurement` is a timestamped datum from a single + /// metric", + /// "type": "object", + /// "required": [ + /// "datum", + /// "timestamp" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Datum" + /// }, + /// "timestamp": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Measurement { + pub datum: Datum, + pub timestamp: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Measurement> for Measurement { + fn from(value: &Measurement) -> Self { + value.clone() + } + } + + impl Measurement { + pub fn builder() -> builder::Measurement { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Measurement" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct MeasurementResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&MeasurementResultsPage> for MeasurementResultsPage { + fn from(value: &MeasurementResultsPage) -> Self { + value.clone() + } + } + + impl MeasurementResultsPage { + pub fn builder() -> builder::MeasurementResultsPage { + Default::default() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Name(::std::string::String); + impl ::std::ops::Deref for Name { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Name) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Name> for Name { + fn from(value: &Name) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Name { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Name { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Name { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///`NameOrId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "id", + /// "allOf": [ + /// { + /// "type": "string", + /// "format": "uuid" + /// } + /// ] + /// }, + /// { + /// "title": "name", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum NameOrId { + Id(::uuid::Uuid), + Name(Name), + } + + impl ::std::convert::From<&Self> for NameOrId { + fn from(value: &NameOrId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for NameOrId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for NameOrId { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::Id(x) => x.fmt(f), + Self::Name(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From<::uuid::Uuid> for NameOrId { + fn from(value: ::uuid::Uuid) -> Self { + Self::Id(value) + } + } + + impl ::std::convert::From for NameOrId { + fn from(value: Name) -> Self { + Self::Name(value) + } + } + + ///Supported set of sort modes for scanning by name or id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name or + /// id", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// }, + /// { + /// "description": "sort in decreasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_descending" + /// ] + /// }, + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum NameOrIdSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + ///sort in decreasing order of "name" + #[serde(rename = "name_descending")] + NameDescending, + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for NameOrIdSortMode { + fn from(value: &NameOrIdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameOrIdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + Self::NameDescending => f.write_str("name_descending"), + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for NameOrIdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + "name_descending" => Ok(Self::NameDescending), + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name + /// only\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum NameSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + } + + impl ::std::convert::From<&Self> for NameSortMode { + fn from(value: &NameSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + } + } + } + + impl ::std::str::FromStr for NameSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `NetworkInterface` represents a virtual network interface device. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `NetworkInterface` represents a virtual network + /// interface device.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "instance_id", + /// "ip", + /// "mac", + /// "name", + /// "primary", + /// "subnet_id", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "instance_id": { + /// "description": "The Instance to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ip": { + /// "description": "The IP address assigned to this interface.", + /// "type": "string", + /// "format": "ip" + /// }, + /// "mac": { + /// "description": "The MAC address assigned to this interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/MacAddr" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "primary": { + /// "description": "True if this interface is the primary for the + /// instance to which it's attached.", + /// "type": "boolean" + /// }, + /// "subnet_id": { + /// "description": "The subnet to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterface { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The Instance to which the interface belongs. + pub instance_id: ::uuid::Uuid, + ///The IP address assigned to this interface. + pub ip: ::std::net::IpAddr, + ///The MAC address assigned to this interface. + pub mac: MacAddr, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///True if this interface is the primary for the instance to which it's + /// attached. + pub primary: bool, + ///The subnet to which the interface belongs. + pub subnet_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the interface belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + impl NetworkInterface { + pub fn builder() -> builder::NetworkInterface { + Default::default() + } + } + + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`NetworkInterface`](omicron_common::api::external::NetworkInterface)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "subnet_name", + /// "vpc_name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ip": { + /// "description": "The IP address for the interface. One will be + /// auto-assigned if not provided.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "ip" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "subnet_name": { + /// "description": "The VPC Subnet in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "vpc_name": { + /// "description": "The VPC in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceCreate { + pub description: ::std::string::String, + ///The IP address for the interface. One will be auto-assigned if not + /// provided. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ip: ::std::option::Option<::std::net::IpAddr>, + pub name: Name, + ///The VPC Subnet in which to create the interface. + pub subnet_name: Name, + ///The VPC in which to create the interface. + pub vpc_name: Name, + } + + impl ::std::convert::From<&NetworkInterfaceCreate> for NetworkInterfaceCreate { + fn from(value: &NetworkInterfaceCreate) -> Self { + value.clone() + } + } + + impl NetworkInterfaceCreate { + pub fn builder() -> builder::NetworkInterfaceCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&NetworkInterfaceResultsPage> for NetworkInterfaceResultsPage { + fn from(value: &NetworkInterfaceResultsPage) -> Self { + value.clone() + } + } + + impl NetworkInterfaceResultsPage { + pub fn builder() -> builder::NetworkInterfaceResultsPage { + Default::default() + } + } + + ///Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface). + /// + ///Note that modifying IP addresses for an interface is not yet supported, + /// a new interface must be created instead. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface).\ + /// n\nNote that modifying IP addresses for an interface is not yet + /// supported, a new interface must be created instead.", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "primary": { + /// "description": "Make a secondary interface the instance's primary + /// interface.\n\nIf applied to a secondary interface, that interface will + /// become the primary on the next reboot of the instance. Note that this + /// may have implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface.\n\nNote that this can only be used to select a new primary + /// interface for an instance. Requests to change the primary interface into + /// a secondary will return an error.", + /// "default": false, + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + ///Make a secondary interface the instance's primary interface. + /// + ///If applied to a secondary interface, that interface will become the + /// primary on the next reboot of the instance. Note that this may have + /// implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface. + /// + ///Note that this can only be used to select a new primary interface + /// for an instance. Requests to change the primary interface into a + /// secondary will return an error. + #[serde(default)] + pub primary: bool, + } + + impl ::std::convert::From<&NetworkInterfaceUpdate> for NetworkInterfaceUpdate { + fn from(value: &NetworkInterfaceUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for NetworkInterfaceUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + primary: Default::default(), + } + } + } + + impl NetworkInterfaceUpdate { + pub fn builder() -> builder::NetworkInterfaceUpdate { + Default::default() + } + } + + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Unique name for a saga [`Node`]\n\nEach node requires a + /// string name that's unique within its DAG. The name is used to identify + /// its output. Nodes that depend on a given node (either directly or + /// indirectly) can access the node's output using its name.", + /// "type": "string" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + #[serde(transparent)] + pub struct NodeName(pub ::std::string::String); + impl ::std::ops::Deref for NodeName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: NodeName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&NodeName> for NodeName { + fn from(value: &NodeName) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::string::String> for NodeName { + fn from(value: ::std::string::String) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for NodeName { + type Err = ::std::convert::Infallible; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.to_string())) + } + } + + impl ::std::fmt::Display for NodeName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of an [`Organization`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Organization`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Organization { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Organization> for Organization { + fn from(value: &Organization) -> Self { + value.clone() + } + } + + impl Organization { + pub fn builder() -> builder::Organization { + Default::default() + } + } + + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&OrganizationCreate> for OrganizationCreate { + fn from(value: &OrganizationCreate) -> Self { + value.clone() + } + } + + impl OrganizationCreate { + pub fn builder() -> builder::OrganizationCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Organization" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&OrganizationResultsPage> for OrganizationResultsPage { + fn from(value: &OrganizationResultsPage) -> Self { + value.clone() + } + } + + impl OrganizationResultsPage { + pub fn builder() -> builder::OrganizationResultsPage { + Default::default() + } + } + + ///`OrganizationRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum OrganizationRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for OrganizationRole { + fn from(value: &OrganizationRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for OrganizationRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for OrganizationRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/OrganizationRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&OrganizationRolePolicy> for OrganizationRolePolicy { + fn from(value: &OrganizationRolePolicy) -> Self { + value.clone() + } + } + + impl OrganizationRolePolicy { + pub fn builder() -> builder::OrganizationRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/OrganizationRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: OrganizationRole, + } + + impl ::std::convert::From<&OrganizationRoleRoleAssignment> for OrganizationRoleRoleAssignment { + fn from(value: &OrganizationRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl OrganizationRoleRoleAssignment { + pub fn builder() -> builder::OrganizationRoleRoleAssignment { + Default::default() + } + } + + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&OrganizationUpdate> for OrganizationUpdate { + fn from(value: &OrganizationUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for OrganizationUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl OrganizationUpdate { + pub fn builder() -> builder::OrganizationUpdate { + Default::default() + } + } + + ///Passwords may be subject to additional constraints. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A password used to authenticate a user", + /// "description": "Passwords may be subject to additional constraints.", + /// "type": "string", + /// "maxLength": 512 + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Password(::std::string::String); + impl ::std::ops::Deref for Password { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Password) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Password> for Password { + fn from(value: &Password) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Password { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 512usize { + return Err("longer than 512 characters".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Password { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Client view of a [`PhysicalDisk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`PhysicalDisk`]", + /// "type": "object", + /// "required": [ + /// "disk_type", + /// "id", + /// "model", + /// "serial", + /// "time_created", + /// "time_modified", + /// "vendor" + /// ], + /// "properties": { + /// "disk_type": { + /// "$ref": "#/components/schemas/PhysicalDiskType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "model": { + /// "type": "string" + /// }, + /// "serial": { + /// "type": "string" + /// }, + /// "sled_id": { + /// "description": "The sled to which this disk is attached, if any.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vendor": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub model: ::std::string::String, + pub serial: ::std::string::String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sled_id: ::std::option::Option<::uuid::Uuid>, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub vendor: ::std::string::String, + } + + impl ::std::convert::From<&PhysicalDisk> for PhysicalDisk { + fn from(value: &PhysicalDisk) -> Self { + value.clone() + } + } + + impl PhysicalDisk { + pub fn builder() -> builder::PhysicalDisk { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/PhysicalDisk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&PhysicalDiskResultsPage> for PhysicalDiskResultsPage { + fn from(value: &PhysicalDiskResultsPage) -> Self { + value.clone() + } + } + + impl PhysicalDiskResultsPage { + pub fn builder() -> builder::PhysicalDiskResultsPage { + Default::default() + } + } + + ///`PhysicalDiskType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "internal", + /// "external" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ::std::convert::From<&Self> for PhysicalDiskType { + fn from(value: &PhysicalDiskType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for PhysicalDiskType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Internal => f.write_str("internal"), + Self::External => f.write_str("external"), + } + } + } + + impl ::std::str::FromStr for PhysicalDiskType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Project`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Project`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "organization_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "organization_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Project { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub organization_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Project> for Project { + fn from(value: &Project) -> Self { + value.clone() + } + } + + impl Project { + pub fn builder() -> builder::Project { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&ProjectCreate> for ProjectCreate { + fn from(value: &ProjectCreate) -> Self { + value.clone() + } + } + + impl ProjectCreate { + pub fn builder() -> builder::ProjectCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Project" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ProjectResultsPage> for ProjectResultsPage { + fn from(value: &ProjectResultsPage) -> Self { + value.clone() + } + } + + impl ProjectResultsPage { + pub fn builder() -> builder::ProjectResultsPage { + Default::default() + } + } + + ///`ProjectRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum ProjectRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for ProjectRole { + fn from(value: &ProjectRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ProjectRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for ProjectRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ProjectRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&ProjectRolePolicy> for ProjectRolePolicy { + fn from(value: &ProjectRolePolicy) -> Self { + value.clone() + } + } + + impl ProjectRolePolicy { + pub fn builder() -> builder::ProjectRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/ProjectRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: ProjectRole, + } + + impl ::std::convert::From<&ProjectRoleRoleAssignment> for ProjectRoleRoleAssignment { + fn from(value: &ProjectRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl ProjectRoleRoleAssignment { + pub fn builder() -> builder::ProjectRoleRoleAssignment { + Default::default() + } + } + + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&ProjectUpdate> for ProjectUpdate { + fn from(value: &ProjectUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for ProjectUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl ProjectUpdate { + pub fn builder() -> builder::ProjectUpdate { + Default::default() + } + } + + ///Client view of an [`Rack`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Rack`]", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Rack { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Rack> for Rack { + fn from(value: &Rack) -> Self { + value.clone() + } + } + + impl Rack { + pub fn builder() -> builder::Rack { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Rack" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RackResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RackResultsPage> for RackResultsPage { + fn from(value: &RackResultsPage) -> Self { + value.clone() + } + } + + impl RackResultsPage { + pub fn builder() -> builder::RackResultsPage { + Default::default() + } + } + + ///Client view of a [`Role`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Role`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/RoleName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Role { + pub description: ::std::string::String, + pub name: RoleName, + } + + impl ::std::convert::From<&Role> for Role { + fn from(value: &Role) -> Self { + value.clone() + } + } + + impl Role { + pub fn builder() -> builder::Role { + Default::default() + } + } + + ///Role names consist of two string components separated by dot ("."). + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name for a built-in role", + /// "description": "Role names consist of two string components separated + /// by dot (\".\").", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": "[a-z-]+\\.[a-z-]+" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct RoleName(::std::string::String); + impl ::std::ops::Deref for RoleName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: RoleName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&RoleName> for RoleName { + fn from(value: &RoleName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for RoleName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| ::regress::Regex::new("[a-z-]+\\.[a-z-]+").unwrap()); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for RoleName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for RoleName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Role" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RoleResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RoleResultsPage> for RoleResultsPage { + fn from(value: &RoleResultsPage) -> Self { + value.clone() + } + } + + impl RoleResultsPage { + pub fn builder() -> builder::RoleResultsPage { + Default::default() + } + } + + ///A `RouteDestination` is used to match traffic with a routing rule, on + /// the destination of that traffic. + /// + ///When traffic is to be sent to a destination that is within a given + /// `RouteDestination`, the corresponding [`RouterRoute`] applies, and + /// traffic will be forward to the [`RouteTarget`] for that rule. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteDestination` is used to match traffic with a + /// routing rule, on the destination of that traffic.\n\nWhen traffic is to + /// be sent to a destination that is within a given `RouteDestination`, the + /// corresponding [`RouterRoute`] applies, and traffic will be forward to + /// the [`RouteTarget`] for that rule.", + /// "oneOf": [ + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for the given + /// VPC.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum RouteDestination { + ///Route applies to traffic destined for a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Route applies to traffic destined for a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + ///Route applies to traffic destined for the given VPC. + #[serde(rename = "vpc")] + Vpc(Name), + ///Route applies to traffic + #[serde(rename = "subnet")] + Subnet(Name), + } + + impl ::std::convert::From<&Self> for RouteDestination { + fn from(value: &RouteDestination) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteDestination { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for RouteDestination { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteTarget` describes the possible locations that + /// traffic matching a route destination can be sent.", + /// "oneOf": [ + /// { + /// "description": "Forward traffic to a particular IP address.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to an internet gateway", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "internet_gateway" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum RouteTarget { + ///Forward traffic to a particular IP address. + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Forward traffic to a VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///Forward traffic to a VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///Forward traffic to a specific instance + #[serde(rename = "instance")] + Instance(Name), + ///Forward traffic to an internet gateway + #[serde(rename = "internet_gateway")] + InternetGateway(Name), + } + + impl ::std::convert::From<&Self> for RouteTarget { + fn from(value: &RouteTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A route defines a rule that governs where traffic + /// should be sent based on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "id", + /// "kind", + /// "name", + /// "target", + /// "time_created", + /// "time_modified", + /// "vpc_router_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "description": "Describes the kind of router. Set at creation. + /// `read-only`", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/RouterRouteKind" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_router_id": { + /// "description": "The VPC Router to which the route belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRoute { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub destination: RouteDestination, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///Describes the kind of router. Set at creation. `read-only` + pub kind: RouterRouteKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub target: RouteTarget, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC Router to which the route belongs. + pub vpc_router_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&RouterRoute> for RouterRoute { + fn from(value: &RouterRoute) -> Self { + value.clone() + } + } + + impl RouterRoute { + pub fn builder() -> builder::RouterRoute { + Default::default() + } + } + + ///Create-time parameters for a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "name", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteCreateParams { + pub description: ::std::string::String, + pub destination: RouteDestination, + pub name: Name, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteCreateParams> for RouterRouteCreateParams { + fn from(value: &RouterRouteCreateParams) -> Self { + value.clone() + } + } + + impl RouterRouteCreateParams { + pub fn builder() -> builder::RouterRouteCreateParams { + Default::default() + } + } + + ///The classification of a [`RouterRoute`] as defined by the system. The + /// kind determines certain attributes such as if the route is modifiable + /// and describes how or where the route was created. + /// + ///See [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The classification of a [`RouterRoute`] as defined by the system. The kind determines certain attributes such as if the route is modifiable and describes how or where the route was created.\n\nSee [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context", + /// "oneOf": [ + /// { + /// "description": "Determines the default destination of traffic, such + /// as whether it goes to the internet or not.\n\n`Destination: An Internet + /// Gateway` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// }, + /// { + /// "description": "Automatically added for each VPC Subnet in the + /// VPC\n\n`Destination: A VPC Subnet` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_subnet" + /// ] + /// }, + /// { + /// "description": "Automatically added when VPC peering is + /// established\n\n`Destination: A different VPC` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_peering" + /// ] + /// }, + /// { + /// "description": "Created by a user See + /// [`RouteTarget`]\n\n`Destination: User defined` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "custom" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` + #[serde(rename = "default")] + Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` + #[serde(rename = "vpc_subnet")] + VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` + #[serde(rename = "vpc_peering")] + VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for RouterRouteKind { + fn from(value: &RouterRouteKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for RouterRouteKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Default => f.write_str("default"), + Self::VpcSubnet => f.write_str("vpc_subnet"), + Self::VpcPeering => f.write_str("vpc_peering"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for RouterRouteKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "default" => Ok(Self::Default), + "vpc_subnet" => Ok(Self::VpcSubnet), + "vpc_peering" => Ok(Self::VpcPeering), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/RouterRoute" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RouterRouteResultsPage> for RouterRouteResultsPage { + fn from(value: &RouterRouteResultsPage) -> Self { + value.clone() + } + } + + impl RouterRouteResultsPage { + pub fn builder() -> builder::RouterRouteResultsPage { + Default::default() + } + } + + ///Updateable properties of a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "destination", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteUpdateParams { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub destination: RouteDestination, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteUpdateParams> for RouterRouteUpdateParams { + fn from(value: &RouterRouteUpdateParams) -> Self { + value.clone() + } + } + + impl RouterRouteUpdateParams { + pub fn builder() -> builder::RouterRouteUpdateParams { + Default::default() + } + } + + ///`Saga` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SagaState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Saga { + pub id: ::uuid::Uuid, + pub state: SagaState, + } + + impl ::std::convert::From<&Saga> for Saga { + fn from(value: &Saga) -> Self { + value.clone() + } + } + + impl Saga { + pub fn builder() -> builder::Saga { + Default::default() + } + } + + ///`SagaErrorInfo` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "source_error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "action_failed" + /// ] + /// }, + /// "source_error": {} + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "deserialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "injected_error" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "serialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "subsaga_create_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "error")] + pub enum SagaErrorInfo { + #[serde(rename = "action_failed")] + ActionFailed { source_error: ::serde_json::Value }, + #[serde(rename = "deserialize_failed")] + DeserializeFailed { message: ::std::string::String }, + #[serde(rename = "injected_error")] + InjectedError, + #[serde(rename = "serialize_failed")] + SerializeFailed { message: ::std::string::String }, + #[serde(rename = "subsaga_create_failed")] + SubsagaCreateFailed { message: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for SagaErrorInfo { + fn from(value: &SagaErrorInfo) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Saga" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SagaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SagaResultsPage> for SagaResultsPage { + fn from(value: &SagaResultsPage) -> Self { + value.clone() + } + } + + impl SagaResultsPage { + pub fn builder() -> builder::SagaResultsPage { + Default::default() + } + } + + ///`SagaState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "succeeded" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error_info", + /// "error_node_name", + /// "state" + /// ], + /// "properties": { + /// "error_info": { + /// "$ref": "#/components/schemas/SagaErrorInfo" + /// }, + /// "error_node_name": { + /// "$ref": "#/components/schemas/NodeName" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "state")] + pub enum SagaState { + #[serde(rename = "running")] + Running, + #[serde(rename = "succeeded")] + Succeeded, + #[serde(rename = "failed")] + Failed { + error_info: SagaErrorInfo, + error_node_name: NodeName, + }, + } + + impl ::std::convert::From<&Self> for SagaState { + fn from(value: &SagaState) -> Self { + value.clone() + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "id", + /// "idp_entity_id", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_cert": { + /// "description": "optional request signing public certificate (base64 + /// encoded der file)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SamlIdentityProvider { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///optional request signing public certificate (base64 encoded der + /// file) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub public_cert: ::std::option::Option<::std::string::String>, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SamlIdentityProvider> for SamlIdentityProvider { + fn from(value: &SamlIdentityProvider) -> Self { + value.clone() + } + } + + impl SamlIdentityProvider { + pub fn builder() -> builder::SamlIdentityProvider { + Default::default() + } + } + + ///Create-time identity-related parameters + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time identity-related parameters", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "idp_entity_id", + /// "idp_metadata_source", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "group_attribute_name": { + /// "description": "If set, SAML attributes with this name will be + /// considered to denote a user's group membership, where the attribute + /// value(s) should be a comma-separated list of group names.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "idp_metadata_source": { + /// "description": "the source of an identity provider metadata + /// descriptor", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdpMetadataSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "signing_keypair": { + /// "description": "optional request signing key pair", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DerEncodedKeyPair" + /// } + /// ] + /// } + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SamlIdentityProviderCreate { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + pub description: ::std::string::String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub group_attribute_name: ::std::option::Option<::std::string::String>, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///the source of an identity provider metadata descriptor + pub idp_metadata_source: IdpMetadataSource, + pub name: Name, + ///optional request signing key pair + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub signing_keypair: ::std::option::Option, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + } + + impl ::std::convert::From<&SamlIdentityProviderCreate> for SamlIdentityProviderCreate { + fn from(value: &SamlIdentityProviderCreate) -> Self { + value.clone() + } + } + + impl SamlIdentityProviderCreate { + pub fn builder() -> builder::SamlIdentityProviderCreate { + Default::default() + } + } + + ///`SemverVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "pattern": "^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct SemverVersion(::std::string::String); + impl ::std::ops::Deref for SemverVersion { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: SemverVersion) -> Self { + value.0 + } + } + + impl ::std::convert::From<&SemverVersion> for SemverVersion { + fn from(value: &SemverVersion) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for SemverVersion { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The service intended to use this certificate. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The service intended to use this certificate.", + /// "oneOf": [ + /// { + /// "description": "This certificate is intended for access to the + /// external API.", + /// "type": "string", + /// "enum": [ + /// "external_api" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ::std::convert::From<&Self> for ServiceUsingCertificate { + fn from(value: &ServiceUsingCertificate) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ServiceUsingCertificate { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::ExternalApi => f.write_str("external_api"), + } + } + } + + impl ::std::str::FromStr for ServiceUsingCertificate { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a ['Silo'] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a ['Silo']", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "id", + /// "identity_mode", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "discoverable": { + /// "description": "A silo where discoverable is false can be retrieved only by its id - it will not be part of the \"list all silos\" output.", + /// "type": "boolean" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_mode": { + /// "description": "How users and groups are managed in this Silo", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Silo { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///A silo where discoverable is false can be retrieved only by its id - + /// it will not be part of the "list all silos" output. + pub discoverable: bool, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Silo> for Silo { + fn from(value: &Silo) -> Self { + value.clone() + } + } + + impl Silo { + pub fn builder() -> builder::Silo { + Default::default() + } + } + + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Silo`](crate::external_api::views::Silo)", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "identity_mode", + /// "name" + /// ], + /// "properties": { + /// "admin_group_name": { + /// "description": "If set, this group will be created during Silo + /// creation and granted the \"Silo Admin\" role. Identity providers can + /// assert that users belong to this group and those users can log in and + /// further initialize the Silo.\n\nNote that if configuring a SAML based + /// identity provider, group_attribute_name must be set for users to be + /// considered part of a group. See [`SamlIdentityProviderCreate`] for more + /// information.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "discoverable": { + /// "type": "boolean" + /// }, + /// "identity_mode": { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub admin_group_name: ::std::option::Option<::std::string::String>, + pub description: ::std::string::String, + pub discoverable: bool, + pub identity_mode: SiloIdentityMode, + pub name: Name, + } + + impl ::std::convert::From<&SiloCreate> for SiloCreate { + fn from(value: &SiloCreate) -> Self { + value.clone() + } + } + + impl SiloCreate { + pub fn builder() -> builder::SiloCreate { + Default::default() + } + } + + ///Describes how identities are managed and users are authenticated in this + /// Silo + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes how identities are managed and users are + /// authenticated in this Silo", + /// "oneOf": [ + /// { + /// "description": "Users are authenticated with SAML using an external + /// authentication provider. The system updates information about users and + /// groups only during successful authentication (i.e,. \"JIT provisioning\" + /// of users and groups).", + /// "type": "string", + /// "enum": [ + /// "saml_jit" + /// ] + /// }, + /// { + /// "description": "The system is the source of truth about users. + /// There is no linkage to an external authentication provider or identity + /// provider.", + /// "type": "string", + /// "enum": [ + /// "local_only" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ::std::convert::From<&Self> for SiloIdentityMode { + fn from(value: &SiloIdentityMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloIdentityMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SamlJit => f.write_str("saml_jit"), + Self::LocalOnly => f.write_str("local_only"), + } + } + } + + impl ::std::str::FromStr for SiloIdentityMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Silo" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SiloResultsPage> for SiloResultsPage { + fn from(value: &SiloResultsPage) -> Self { + value.clone() + } + } + + impl SiloResultsPage { + pub fn builder() -> builder::SiloResultsPage { + Default::default() + } + } + + ///`SiloRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SiloRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for SiloRole { + fn from(value: &SiloRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for SiloRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SiloRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&SiloRolePolicy> for SiloRolePolicy { + fn from(value: &SiloRolePolicy) -> Self { + value.clone() + } + } + + impl SiloRolePolicy { + pub fn builder() -> builder::SiloRolePolicy { + Default::default() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/SiloRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: SiloRole, + } + + impl ::std::convert::From<&SiloRoleRoleAssignment> for SiloRoleRoleAssignment { + fn from(value: &SiloRoleRoleAssignment) -> Self { + value.clone() + } + } + + impl SiloRoleRoleAssignment { + pub fn builder() -> builder::SiloRoleRoleAssignment { + Default::default() + } + } + + ///Client view of a [`Sled`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Sled`]", + /// "type": "object", + /// "required": [ + /// "baseboard", + /// "id", + /// "service_address", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "baseboard": { + /// "$ref": "#/components/schemas/Baseboard" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "service_address": { + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Sled { + pub baseboard: Baseboard, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub service_address: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Sled> for Sled { + fn from(value: &Sled) -> Self { + value.clone() + } + } + + impl Sled { + pub fn builder() -> builder::Sled { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Sled" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SledResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SledResultsPage> for SledResultsPage { + fn from(value: &SledResultsPage) -> Self { + value.clone() + } + } + + impl SledResultsPage { + pub fn builder() -> builder::SledResultsPage { + Default::default() + } + } + + ///Client view of a Snapshot + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a Snapshot", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_id", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SnapshotState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Snapshot { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub disk_id: ::uuid::Uuid, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + pub state: SnapshotState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Snapshot> for Snapshot { + fn from(value: &Snapshot) -> Self { + value.clone() + } + } + + impl Snapshot { + pub fn builder() -> builder::Snapshot { + Default::default() + } + } + + ///Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk": { + /// "description": "The name of the disk to be snapshotted", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SnapshotCreate { + pub description: ::std::string::String, + ///The name of the disk to be snapshotted + pub disk: Name, + pub name: Name, + } + + impl ::std::convert::From<&SnapshotCreate> for SnapshotCreate { + fn from(value: &SnapshotCreate) -> Self { + value.clone() + } + } + + impl SnapshotCreate { + pub fn builder() -> builder::SnapshotCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Snapshot" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SnapshotResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SnapshotResultsPage> for SnapshotResultsPage { + fn from(value: &SnapshotResultsPage) -> Self { + value.clone() + } + } + + impl SnapshotResultsPage { + pub fn builder() -> builder::SnapshotResultsPage { + Default::default() + } + } + + ///`SnapshotState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "creating", + /// "ready", + /// "faulted", + /// "destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for SnapshotState { + fn from(value: &SnapshotState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SnapshotState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Ready => f.write_str("ready"), + Self::Faulted => f.write_str("faulted"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for SnapshotState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`SpoofLoginBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "username" + /// ], + /// "properties": { + /// "username": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SpoofLoginBody { + pub username: ::std::string::String, + } + + impl ::std::convert::From<&SpoofLoginBody> for SpoofLoginBody { + fn from(value: &SpoofLoginBody) -> Self { + value.clone() + } + } + + impl SpoofLoginBody { + pub fn builder() -> builder::SpoofLoginBody { + Default::default() + } + } + + ///Client view of a [`SshKey`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`SshKey`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "public_key", + /// "silo_user_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// }, + /// "silo_user_id": { + /// "description": "The user to whom this key belongs", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKey { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + ///The user to whom this key belongs + pub silo_user_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SshKey> for SshKey { + fn from(value: &SshKey) -> Self { + value.clone() + } + } + + impl SshKey { + pub fn builder() -> builder::SshKey { + Default::default() + } + } + + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "public_key" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKeyCreate { + pub description: ::std::string::String, + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + } + + impl ::std::convert::From<&SshKeyCreate> for SshKeyCreate { + fn from(value: &SshKeyCreate) -> Self { + value.clone() + } + } + + impl SshKeyCreate { + pub fn builder() -> builder::SshKeyCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SshKey" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKeyResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SshKeyResultsPage> for SshKeyResultsPage { + fn from(value: &SshKeyResultsPage) -> Self { + value.clone() + } + } + + impl SshKeyResultsPage { + pub fn builder() -> builder::SshKeyResultsPage { + Default::default() + } + } + + ///`SystemMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "virtual_disk_space_provisioned", + /// "cpus_provisioned", + /// "ram_provisioned" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ::std::convert::From<&Self> for SystemMetricName { + fn from(value: &SystemMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SystemMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::VirtualDiskSpaceProvisioned => f.write_str("virtual_disk_space_provisioned"), + Self::CpusProvisioned => f.write_str("cpus_provisioned"), + Self::RamProvisioned => f.write_str("ram_provisioned"), + } + } + } + + impl ::std::str::FromStr for SystemMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdate> for SystemUpdate { + fn from(value: &SystemUpdate) -> Self { + value.clone() + } + } + + impl SystemUpdate { + pub fn builder() -> builder::SystemUpdate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SystemUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SystemUpdateResultsPage> for SystemUpdateResultsPage { + fn from(value: &SystemUpdateResultsPage) -> Self { + value.clone() + } + } + + impl SystemUpdateResultsPage { + pub fn builder() -> builder::SystemUpdateResultsPage { + Default::default() + } + } + + ///`SystemUpdateStart` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "version" + /// ], + /// "properties": { + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdateStart> for SystemUpdateStart { + fn from(value: &SystemUpdateStart) -> Self { + value.clone() + } + } + + impl SystemUpdateStart { + pub fn builder() -> builder::SystemUpdateStart { + Default::default() + } + } + + ///`SystemVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "status", + /// "version_range" + /// ], + /// "properties": { + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "version_range": { + /// "$ref": "#/components/schemas/VersionRange" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + + impl ::std::convert::From<&SystemVersion> for SystemVersion { + fn from(value: &SystemVersion) -> Self { + value.clone() + } + } + + impl SystemVersion { + pub fn builder() -> builder::SystemVersion { + Default::default() + } + } + + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "The name of a timeseries", + /// "description": "Names are constructed by concatenating the target and + /// metric names with ':'. Target and metric names must be lowercase + /// alphanumeric characters with '_' separating words.", + /// "type": "string", + /// "pattern": + /// "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct TimeseriesName(::std::string::String); + impl ::std::ops::Deref for TimeseriesName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: TimeseriesName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&TimeseriesName> for TimeseriesName { + fn from(value: &TimeseriesName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for TimeseriesName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ + )(_([a-z0-9]+))*)\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for TimeseriesName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The schema for a timeseries. + /// + ///This includes the name of the timeseries, as well as the datum type of + /// its metric and the schema for each field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The schema for a timeseries.\n\nThis includes the name + /// of the timeseries, as well as the datum type of its metric and the + /// schema for each field.", + /// "type": "object", + /// "required": [ + /// "created", + /// "datum_type", + /// "field_schema", + /// "timeseries_name" + /// ], + /// "properties": { + /// "created": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "datum_type": { + /// "$ref": "#/components/schemas/DatumType" + /// }, + /// "field_schema": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FieldSchema" + /// } + /// }, + /// "timeseries_name": { + /// "$ref": "#/components/schemas/TimeseriesName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TimeseriesSchema { + pub created: ::chrono::DateTime<::chrono::offset::Utc>, + pub datum_type: DatumType, + pub field_schema: ::std::vec::Vec, + pub timeseries_name: TimeseriesName, + } + + impl ::std::convert::From<&TimeseriesSchema> for TimeseriesSchema { + fn from(value: &TimeseriesSchema) -> Self { + value.clone() + } + } + + impl TimeseriesSchema { + pub fn builder() -> builder::TimeseriesSchema { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/TimeseriesSchema" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TimeseriesSchemaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&TimeseriesSchemaResultsPage> for TimeseriesSchemaResultsPage { + fn from(value: &TimeseriesSchemaResultsPage) -> Self { + value.clone() + } + } + + impl TimeseriesSchemaResultsPage { + pub fn builder() -> builder::TimeseriesSchemaResultsPage { + Default::default() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "status", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateDeployment> for UpdateDeployment { + fn from(value: &UpdateDeployment) -> Self { + value.clone() + } + } + + impl UpdateDeployment { + pub fn builder() -> builder::UpdateDeployment { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateDeployment" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateDeploymentResultsPage> for UpdateDeploymentResultsPage { + fn from(value: &UpdateDeploymentResultsPage) -> Self { + value.clone() + } + } + + impl UpdateDeploymentResultsPage { + pub fn builder() -> builder::UpdateDeploymentResultsPage { + Default::default() + } + } + + ///`UpdateStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "updating" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "steady" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ::std::convert::From<&Self> for UpdateStatus { + fn from(value: &UpdateStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Updating => f.write_str("updating"), + Self::Steady => f.write_str("steady"), + } + } + } + + impl ::std::str::FromStr for UpdateStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "device_id", + /// "id", + /// "status", + /// "system_version", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "device_id": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "system_version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateableComponent> for UpdateableComponent { + fn from(value: &UpdateableComponent) -> Self { + value.clone() + } + } + + impl UpdateableComponent { + pub fn builder() -> builder::UpdateableComponent { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateableComponent" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateableComponentResultsPage> for UpdateableComponentResultsPage { + fn from(value: &UpdateableComponentResultsPage) -> Self { + value.clone() + } + } + + impl UpdateableComponentResultsPage { + pub fn builder() -> builder::UpdateableComponentResultsPage { + Default::default() + } + } + + ///`UpdateableComponentType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "bootloader_for_rot", + /// "bootloader_for_sp", + /// "bootloader_for_host_proc", + /// "hubris_for_psc_rot", + /// "hubris_for_psc_sp", + /// "hubris_for_sidecar_rot", + /// "hubris_for_sidecar_sp", + /// "hubris_for_gimlet_rot", + /// "hubris_for_gimlet_sp", + /// "helios_host_phase1", + /// "helios_host_phase2", + /// "host_omicron" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ::std::convert::From<&Self> for UpdateableComponentType { + fn from(value: &UpdateableComponentType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateableComponentType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::BootloaderForRot => f.write_str("bootloader_for_rot"), + Self::BootloaderForSp => f.write_str("bootloader_for_sp"), + Self::BootloaderForHostProc => f.write_str("bootloader_for_host_proc"), + Self::HubrisForPscRot => f.write_str("hubris_for_psc_rot"), + Self::HubrisForPscSp => f.write_str("hubris_for_psc_sp"), + Self::HubrisForSidecarRot => f.write_str("hubris_for_sidecar_rot"), + Self::HubrisForSidecarSp => f.write_str("hubris_for_sidecar_sp"), + Self::HubrisForGimletRot => f.write_str("hubris_for_gimlet_rot"), + Self::HubrisForGimletSp => f.write_str("hubris_for_gimlet_sp"), + Self::HeliosHostPhase1 => f.write_str("helios_host_phase1"), + Self::HeliosHostPhase2 => f.write_str("helios_host_phase2"), + Self::HostOmicron => f.write_str("host_omicron"), + } + } + } + + impl ::std::str::FromStr for UpdateableComponentType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`User`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`User`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the user", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this user belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct User { + ///Human-readable name that can identify the user + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + impl User { + pub fn builder() -> builder::User { + Default::default() + } + } + + ///Client view of a [`UserBuiltin`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`UserBuiltin`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserBuiltin { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&UserBuiltin> for UserBuiltin { + fn from(value: &UserBuiltin) -> Self { + value.clone() + } + } + + impl UserBuiltin { + pub fn builder() -> builder::UserBuiltin { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UserBuiltin" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserBuiltinResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserBuiltinResultsPage> for UserBuiltinResultsPage { + fn from(value: &UserBuiltinResultsPage) -> Self { + value.clone() + } + } + + impl UserBuiltinResultsPage { + pub fn builder() -> builder::UserBuiltinResultsPage { + Default::default() + } + } + + ///Create-time parameters for a [`User`](crate::external_api::views::User) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`User`](crate::external_api::views::User)", + /// "type": "object", + /// "required": [ + /// "external_id", + /// "password" + /// ], + /// "properties": { + /// "external_id": { + /// "description": "username used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserId" + /// } + /// ] + /// }, + /// "password": { + /// "description": "password used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserPassword" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + impl UserCreate { + pub fn builder() -> builder::UserCreate { + Default::default() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct UserId(::std::string::String); + impl ::std::ops::Deref for UserId { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: UserId) -> Self { + value.0 + } + } + + impl ::std::convert::From<&UserId> for UserId { + fn from(value: &UserId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for UserId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for UserId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Parameters for setting a user's password + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for setting a user's password", + /// "oneOf": [ + /// { + /// "description": "Sets the user's password to the provided value", + /// "type": "object", + /// "required": [ + /// "details", + /// "user_password_value" + /// ], + /// "properties": { + /// "details": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "password" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Invalidates any current password (disabling + /// password authentication)", + /// "type": "object", + /// "required": [ + /// "user_password_value" + /// ], + /// "properties": { + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "invalid_password" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + + impl ::std::convert::From<&Self> for UserPassword { + fn from(value: &UserPassword) -> Self { + value.clone() + } + } + + impl ::std::convert::From for UserPassword { + fn from(value: Password) -> Self { + Self::Password(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/User" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserResultsPage> for UserResultsPage { + fn from(value: &UserResultsPage) -> Self { + value.clone() + } + } + + impl UserResultsPage { + pub fn builder() -> builder::UserResultsPage { + Default::default() + } + } + + ///Credentials for local user login + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Credentials for local user login", + /// "type": "object", + /// "required": [ + /// "password", + /// "username" + /// ], + /// "properties": { + /// "password": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "username": { + /// "$ref": "#/components/schemas/UserId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + impl ::std::convert::From<&UsernamePasswordCredentials> for UsernamePasswordCredentials { + fn from(value: &UsernamePasswordCredentials) -> Self { + value.clone() + } + } + + impl UsernamePasswordCredentials { + pub fn builder() -> builder::UsernamePasswordCredentials { + Default::default() + } + } + + ///`VersionRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "high", + /// "low" + /// ], + /// "properties": { + /// "high": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "low": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + + impl ::std::convert::From<&VersionRange> for VersionRange { + fn from(value: &VersionRange) -> Self { + value.clone() + } + } + + impl VersionRange { + pub fn builder() -> builder::VersionRange { + Default::default() + } + } + + ///Client view of a [`Vpc`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Vpc`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "id", + /// "ipv6_prefix", + /// "name", + /// "project_id", + /// "system_router_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "dns_name": { + /// "description": "The name used for the VPC in DNS.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv6_prefix": { + /// "description": "The unique local IPv6 address range for subnets in + /// this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this VPC", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "system_router_id": { + /// "description": "id for the system router where subnet default + /// routes are registered", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Vpc { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///The name used for the VPC in DNS. + pub dns_name: Name, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The unique local IPv6 address range for subnets in this VPC + pub ipv6_prefix: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///id for the project containing this VPC + pub project_id: ::uuid::Uuid, + ///id for the system router where subnet default routes are registered + pub system_router_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Vpc> for Vpc { + fn from(value: &Vpc) -> Self { + value.clone() + } + } + + impl Vpc { + pub fn builder() -> builder::Vpc { + Default::default() + } + } + + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "dns_name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ipv6_prefix": { + /// "description": "The IPv6 prefix for this VPC.\n\nAll IPv6 subnets + /// created from this VPC must be taken from this range, which sould be a + /// Unique Local Address in the range `fd00::/48`. The default VPC Subnet + /// will have the first `/64` range from this prefix.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcCreate { + pub description: ::std::string::String, + pub dns_name: Name, + ///The IPv6 prefix for this VPC. + /// + ///All IPv6 subnets created from this VPC must be taken from this + /// range, which sould be a Unique Local Address in the range + /// `fd00::/48`. The default VPC Subnet will have the first `/64` range + /// from this prefix. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_prefix: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcCreate> for VpcCreate { + fn from(value: &VpcCreate) -> Self { + value.clone() + } + } + + impl VpcCreate { + pub fn builder() -> builder::VpcCreate { + Default::default() + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "id", + /// "name", + /// "priority", + /// "status", + /// "targets", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "the VPC to which this rule belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRule { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///the VPC to which this rule belongs + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcFirewallRule> for VpcFirewallRule { + fn from(value: &VpcFirewallRule) -> Self { + value.clone() + } + } + + impl VpcFirewallRule { + pub fn builder() -> builder::VpcFirewallRule { + Default::default() + } + } + + ///`VpcFirewallRuleAction` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "allow", + /// "deny" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleAction { + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleAction { + fn from(value: &VpcFirewallRuleAction) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleAction { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Allow => f.write_str("allow"), + Self::Deny => f.write_str("deny"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleAction { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "allow" => Ok(Self::Allow), + "deny" => Ok(Self::Deny), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleDirection` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "inbound", + /// "outbound" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleDirection { + #[serde(rename = "inbound")] + Inbound, + #[serde(rename = "outbound")] + Outbound, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleDirection { + fn from(value: &VpcFirewallRuleDirection) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleDirection { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Inbound => f.write_str("inbound"), + Self::Outbound => f.write_str("outbound"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleDirection { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "inbound" => Ok(Self::Inbound), + "outbound" => Ok(Self::Outbound), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Filter for a firewall rule. A given packet must match every field that + /// is present for the rule to apply to it. A packet matches a field if any + /// entry in that field matches the packet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Filter for a firewall rule. A given packet must match + /// every field that is present for the rule to apply to it. A packet + /// matches a field if any entry in that field matches the packet.", + /// "type": "object", + /// "properties": { + /// "hosts": { + /// "description": "If present, the sources (if incoming) or + /// destinations (if outgoing) this rule applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleHostFilter" + /// } + /// }, + /// "ports": { + /// "description": "If present, the destination ports this rule applies + /// to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/L4PortRange" + /// } + /// }, + /// "protocols": { + /// "description": "If present, the networking protocols this rule + /// applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleProtocol" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleFilter { + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub hosts: ::std::option::Option<::std::vec::Vec>, + ///If present, the destination ports this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ports: ::std::option::Option<::std::vec::Vec>, + ///If present, the networking protocols this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub protocols: ::std::option::Option<::std::vec::Vec>, + } + + impl ::std::convert::From<&VpcFirewallRuleFilter> for VpcFirewallRuleFilter { + fn from(value: &VpcFirewallRuleFilter) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcFirewallRuleFilter { + fn default() -> Self { + Self { + hosts: Default::default(), + ports: Default::default(), + protocols: Default::default(), + } + } + } + + impl VpcFirewallRuleFilter { + pub fn builder() -> builder::VpcFirewallRuleFilter { + Default::default() + } + } + + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `VpcFirewallRuleHostFilter` is used to filter + /// traffic on the basis of its source or destination host.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to this specific + /// instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleHostFilter { + ///The rule applies to traffic from/to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to traffic from/to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to traffic from/to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to traffic from/to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to traffic from/to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleHostFilter { + fn from(value: &VpcFirewallRuleHostFilter) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleHostFilter { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleHostFilter { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///The protocols that may be specified in a firewall rule's filter + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The protocols that may be specified in a firewall + /// rule's filter", + /// "type": "string", + /// "enum": [ + /// "TCP", + /// "UDP", + /// "ICMP" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleProtocol { + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, + #[serde(rename = "ICMP")] + Icmp, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleProtocol { + fn from(value: &VpcFirewallRuleProtocol) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleProtocol { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Tcp => f.write_str("TCP"), + Self::Udp => f.write_str("UDP"), + Self::Icmp => f.write_str("ICMP"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleProtocol { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "TCP" => Ok(Self::Tcp), + "UDP" => Ok(Self::Udp), + "ICMP" => Ok(Self::Icmp), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "disabled", + /// "enabled" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleStatus { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleStatus { + fn from(value: &VpcFirewallRuleStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Disabled => f.write_str("disabled"), + Self::Enabled => f.write_str("enabled"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "disabled" => Ok(Self::Disabled), + "enabled" => Ok(Self::Enabled), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `VpcFirewallRuleTarget` is used to specify the set of + /// [`Instance`]s to which a firewall rule applies.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to all instances in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to all instances in the VPC + /// Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to this specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleTarget { + ///The rule applies to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleTarget { + fn from(value: &VpcFirewallRuleTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleTarget { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "name", + /// "priority", + /// "status", + /// "targets" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "name": { + /// "description": "name of the rule, unique to this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleUpdate { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///name of the rule, unique to this VPC + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdate> for VpcFirewallRuleUpdate { + fn from(value: &VpcFirewallRuleUpdate) -> Self { + value.clone() + } + } + + impl VpcFirewallRuleUpdate { + pub fn builder() -> builder::VpcFirewallRuleUpdate { + Default::default() + } + } + + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a `Vpc`'s firewall Note that + /// VpcFirewallRules are implicitly created along with a Vpc, so there is no + /// explicit creation.", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleUpdate" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleUpdateParams { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdateParams> for VpcFirewallRuleUpdateParams { + fn from(value: &VpcFirewallRuleUpdateParams) -> Self { + value.clone() + } + } + + impl VpcFirewallRuleUpdateParams { + pub fn builder() -> builder::VpcFirewallRuleUpdateParams { + Default::default() + } + } + + ///Collection of a Vpc's firewall rules + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Collection of a Vpc's firewall rules", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRule" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRules { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRules> for VpcFirewallRules { + fn from(value: &VpcFirewallRules) -> Self { + value.clone() + } + } + + impl VpcFirewallRules { + pub fn builder() -> builder::VpcFirewallRules { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Vpc" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcResultsPage> for VpcResultsPage { + fn from(value: &VpcResultsPage) -> Self { + value.clone() + } + } + + impl VpcResultsPage { + pub fn builder() -> builder::VpcResultsPage { + Default::default() + } + } + + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC router defines a series of rules that indicate + /// where traffic should be sent depending on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "kind", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/VpcRouterKind" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the router belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouter { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub kind: VpcRouterKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the router belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcRouter> for VpcRouter { + fn from(value: &VpcRouter) -> Self { + value.clone() + } + } + + impl VpcRouter { + pub fn builder() -> builder::VpcRouter { + Default::default() + } + } + + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&VpcRouterCreate> for VpcRouterCreate { + fn from(value: &VpcRouterCreate) -> Self { + value.clone() + } + } + + impl VpcRouterCreate { + pub fn builder() -> builder::VpcRouterCreate { + Default::default() + } + } + + ///`VpcRouterKind` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "system", + /// "custom" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcRouterKind { + #[serde(rename = "system")] + System, + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for VpcRouterKind { + fn from(value: &VpcRouterKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcRouterKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::System => f.write_str("system"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for VpcRouterKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "system" => Ok(Self::System), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcRouter" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcRouterResultsPage> for VpcRouterResultsPage { + fn from(value: &VpcRouterResultsPage) -> Self { + value.clone() + } + } + + impl VpcRouterResultsPage { + pub fn builder() -> builder::VpcRouterResultsPage { + Default::default() + } + } + + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcRouterUpdate> for VpcRouterUpdate { + fn from(value: &VpcRouterUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcRouterUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl VpcRouterUpdate { + pub fn builder() -> builder::VpcRouterUpdate { + Default::default() + } + } + + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC subnet represents a logical grouping for + /// instances that allows network traffic between them, within a IPv4 + /// subnetwork or optionall an IPv6 subnetwork.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "ipv4_block", + /// "ipv6_block", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the subnet belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnet { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The IPv4 subnet CIDR block. + pub ipv4_block: Ipv4Net, + ///The IPv6 subnet CIDR block. + pub ipv6_block: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the subnet belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcSubnet> for VpcSubnet { + fn from(value: &VpcSubnet) -> Self { + value.clone() + } + } + + impl VpcSubnet { + pub fn builder() -> builder::VpcSubnet { + Default::default() + } + } + + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "required": [ + /// "description", + /// "ipv4_block", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 address range for this subnet.\n\nIt must + /// be allocated from an RFC 1918 private address range, and must not + /// overlap with any other existing subnet in the VPC.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 address range for this subnet.\n\nIt must + /// be allocated from the RFC 4193 Unique Local Address range, with the + /// prefix equal to the parent VPC's prefix. A random `/64` block will be + /// assigned if one is not provided. It must not overlap with any existing + /// subnet in the VPC.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetCreate { + pub description: ::std::string::String, + ///The IPv4 address range for this subnet. + /// + ///It must be allocated from an RFC 1918 private address range, and + /// must not overlap with any other existing subnet in the VPC. + pub ipv4_block: Ipv4Net, + ///The IPv6 address range for this subnet. + /// + ///It must be allocated from the RFC 4193 Unique Local Address range, + /// with the prefix equal to the parent VPC's prefix. A random `/64` + /// block will be assigned if one is not provided. It must not overlap + /// with any existing subnet in the VPC. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_block: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcSubnetCreate> for VpcSubnetCreate { + fn from(value: &VpcSubnetCreate) -> Self { + value.clone() + } + } + + impl VpcSubnetCreate { + pub fn builder() -> builder::VpcSubnetCreate { + Default::default() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcSubnet" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcSubnetResultsPage> for VpcSubnetResultsPage { + fn from(value: &VpcSubnetResultsPage) -> Self { + value.clone() + } + } + + impl VpcSubnetResultsPage { + pub fn builder() -> builder::VpcSubnetResultsPage { + Default::default() + } + } + + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcSubnetUpdate> for VpcSubnetUpdate { + fn from(value: &VpcSubnetUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcSubnetUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + impl VpcSubnetUpdate { + pub fn builder() -> builder::VpcSubnetUpdate { + Default::default() + } + } + + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "dns_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub dns_name: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcUpdate> for VpcUpdate { + fn from(value: &VpcUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcUpdate { + fn default() -> Self { + Self { + description: Default::default(), + dns_name: Default::default(), + name: Default::default(), + } + } + } + + impl VpcUpdate { + pub fn builder() -> builder::VpcUpdate { + Default::default() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct Baseboard { + part: ::std::result::Result<::std::string::String, ::std::string::String>, + revision: ::std::result::Result, + serial: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Baseboard { + fn default() -> Self { + Self { + part: Err("no value supplied for part".to_string()), + revision: Err("no value supplied for revision".to_string()), + serial: Err("no value supplied for serial".to_string()), + } + } + } + + impl Baseboard { + pub fn part(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.part = value + .try_into() + .map_err(|e| format!("error converting supplied value for part: {}", e)); + self + } + pub fn revision(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.revision = value + .try_into() + .map_err(|e| format!("error converting supplied value for revision: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Baseboard { + type Error = super::error::ConversionError; + fn try_from( + value: Baseboard, + ) -> ::std::result::Result { + Ok(Self { + part: value.part?, + revision: value.revision?, + serial: value.serial?, + }) + } + } + + impl ::std::convert::From for Baseboard { + fn from(value: super::Baseboard) -> Self { + Self { + part: Ok(value.part), + revision: Ok(value.revision), + serial: Ok(value.serial), + } + } + } + + #[derive(Clone, Debug)] + pub struct Bindouble { + count: ::std::result::Result, + range: ::std::result::Result, + } + + impl ::std::default::Default for Bindouble { + fn default() -> Self { + Self { + count: Err("no value supplied for count".to_string()), + range: Err("no value supplied for range".to_string()), + } + } + } + + impl Bindouble { + pub fn count(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Bindouble { + type Error = super::error::ConversionError; + fn try_from( + value: Bindouble, + ) -> ::std::result::Result { + Ok(Self { + count: value.count?, + range: value.range?, + }) + } + } + + impl ::std::convert::From for Bindouble { + fn from(value: super::Bindouble) -> Self { + Self { + count: Ok(value.count), + range: Ok(value.range), + } + } + } + + #[derive(Clone, Debug)] + pub struct Binint64 { + count: ::std::result::Result, + range: ::std::result::Result, + } + + impl ::std::default::Default for Binint64 { + fn default() -> Self { + Self { + count: Err("no value supplied for count".to_string()), + range: Err("no value supplied for range".to_string()), + } + } + } + + impl Binint64 { + pub fn count(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.count = value + .try_into() + .map_err(|e| format!("error converting supplied value for count: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Binint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Binint64, + ) -> ::std::result::Result { + Ok(Self { + count: value.count?, + range: value.range?, + }) + } + } + + impl ::std::convert::From for Binint64 { + fn from(value: super::Binint64) -> Self { + Self { + count: Ok(value.count), + range: Ok(value.range), + } + } + } + + #[derive(Clone, Debug)] + pub struct Certificate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + service: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Certificate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Certificate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Certificate { + type Error = super::error::ConversionError; + fn try_from( + value: Certificate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + service: value.service?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Certificate { + fn from(value: super::Certificate) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + service: Ok(value.service), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct CertificateCreate { + cert: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + key: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + name: ::std::result::Result, + service: ::std::result::Result, + } + + impl ::std::default::Default for CertificateCreate { + fn default() -> Self { + Self { + cert: Err("no value supplied for cert".to_string()), + description: Err("no value supplied for description".to_string()), + key: Err("no value supplied for key".to_string()), + name: Err("no value supplied for name".to_string()), + service: Err("no value supplied for service".to_string()), + } + } + } + + impl CertificateCreate { + pub fn cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn service(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.service = value + .try_into() + .map_err(|e| format!("error converting supplied value for service: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CertificateCreate { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateCreate, + ) -> ::std::result::Result { + Ok(Self { + cert: value.cert?, + description: value.description?, + key: value.key?, + name: value.name?, + service: value.service?, + }) + } + } + + impl ::std::convert::From for CertificateCreate { + fn from(value: super::CertificateCreate) -> Self { + Self { + cert: Ok(value.cert), + description: Ok(value.description), + key: Ok(value.key), + name: Ok(value.name), + service: Ok(value.service), + } + } + } + + #[derive(Clone, Debug)] + pub struct CertificateResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for CertificateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl CertificateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CertificateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for CertificateResultsPage { + fn from(value: super::CertificateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct ComponentUpdate { + component_type: + ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for ComponentUpdate { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl ComponentUpdate { + pub fn component_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ComponentUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdate, + ) -> ::std::result::Result { + Ok(Self { + component_type: value.component_type?, + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for ComponentUpdate { + fn from(value: super::ComponentUpdate) -> Self { + Self { + component_type: Ok(value.component_type), + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct ComponentUpdateResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ComponentUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ComponentUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ComponentUpdateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ComponentUpdateResultsPage { + fn from(value: super::ComponentUpdateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Cumulativedouble { + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + value: ::std::result::Result, + } + + impl ::std::default::Default for Cumulativedouble { + fn default() -> Self { + Self { + start_time: Err("no value supplied for start_time".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl Cumulativedouble { + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Cumulativedouble { + type Error = super::error::ConversionError; + fn try_from( + value: Cumulativedouble, + ) -> ::std::result::Result { + Ok(Self { + start_time: value.start_time?, + value: value.value?, + }) + } + } + + impl ::std::convert::From for Cumulativedouble { + fn from(value: super::Cumulativedouble) -> Self { + Self { + start_time: Ok(value.start_time), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct Cumulativeint64 { + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + value: ::std::result::Result, + } + + impl ::std::default::Default for Cumulativeint64 { + fn default() -> Self { + Self { + start_time: Err("no value supplied for start_time".to_string()), + value: Err("no value supplied for value".to_string()), + } + } + } + + impl Cumulativeint64 { + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + pub fn value(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.value = value + .try_into() + .map_err(|e| format!("error converting supplied value for value: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Cumulativeint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Cumulativeint64, + ) -> ::std::result::Result { + Ok(Self { + start_time: value.start_time?, + value: value.value?, + }) + } + } + + impl ::std::convert::From for Cumulativeint64 { + fn from(value: super::Cumulativeint64) -> Self { + Self { + start_time: Ok(value.start_time), + value: Ok(value.value), + } + } + } + + #[derive(Clone, Debug)] + pub struct DerEncodedKeyPair { + private_key: ::std::result::Result<::std::string::String, ::std::string::String>, + public_cert: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DerEncodedKeyPair { + fn default() -> Self { + Self { + private_key: Err("no value supplied for private_key".to_string()), + public_cert: Err("no value supplied for public_cert".to_string()), + } + } + } + + impl DerEncodedKeyPair { + pub fn private_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.private_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for private_key: {}", e)); + self + } + pub fn public_cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_cert: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DerEncodedKeyPair { + type Error = super::error::ConversionError; + fn try_from( + value: DerEncodedKeyPair, + ) -> ::std::result::Result { + Ok(Self { + private_key: value.private_key?, + public_cert: value.public_cert?, + }) + } + } + + impl ::std::convert::From for DerEncodedKeyPair { + fn from(value: super::DerEncodedKeyPair) -> Self { + Self { + private_key: Ok(value.private_key), + public_cert: Ok(value.public_cert), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAccessTokenRequest { + client_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + device_code: ::std::result::Result<::std::string::String, ::std::string::String>, + grant_type: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAccessTokenRequest { + fn default() -> Self { + Self { + client_id: Err("no value supplied for client_id".to_string()), + device_code: Err("no value supplied for device_code".to_string()), + grant_type: Err("no value supplied for grant_type".to_string()), + } + } + } + + impl DeviceAccessTokenRequest { + pub fn client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.client_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for client_id: {}", e)); + self + } + pub fn device_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_code: {}", e)); + self + } + pub fn grant_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.grant_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for grant_type: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAccessTokenRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAccessTokenRequest, + ) -> ::std::result::Result { + Ok(Self { + client_id: value.client_id?, + device_code: value.device_code?, + grant_type: value.grant_type?, + }) + } + } + + impl ::std::convert::From for DeviceAccessTokenRequest { + fn from(value: super::DeviceAccessTokenRequest) -> Self { + Self { + client_id: Ok(value.client_id), + device_code: Ok(value.device_code), + grant_type: Ok(value.grant_type), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAuthRequest { + client_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAuthRequest { + fn default() -> Self { + Self { + client_id: Err("no value supplied for client_id".to_string()), + } + } + } + + impl DeviceAuthRequest { + pub fn client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.client_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for client_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAuthRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAuthRequest, + ) -> ::std::result::Result { + Ok(Self { + client_id: value.client_id?, + }) + } + } + + impl ::std::convert::From for DeviceAuthRequest { + fn from(value: super::DeviceAuthRequest) -> Self { + Self { + client_id: Ok(value.client_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct DeviceAuthVerify { + user_code: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for DeviceAuthVerify { + fn default() -> Self { + Self { + user_code: Err("no value supplied for user_code".to_string()), + } + } + } + + impl DeviceAuthVerify { + pub fn user_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.user_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for user_code: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DeviceAuthVerify { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAuthVerify, + ) -> ::std::result::Result { + Ok(Self { + user_code: value.user_code?, + }) + } + } + + impl ::std::convert::From for DeviceAuthVerify { + fn from(value: super::DeviceAuthVerify) -> Self { + Self { + user_code: Ok(value.user_code), + } + } + } + + #[derive(Clone, Debug)] + pub struct Disk { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + device_path: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + image_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + snapshot_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Disk { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + device_path: Err("no value supplied for device_path".to_string()), + id: Err("no value supplied for id".to_string()), + image_id: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + snapshot_id: Ok(Default::default()), + state: Err("no value supplied for state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Disk { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn device_path(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_path = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_path: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn image_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.image_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for image_id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn snapshot_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.snapshot_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for snapshot_id: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Disk { + type Error = super::error::ConversionError; + fn try_from(value: Disk) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + device_path: value.device_path?, + id: value.id?, + image_id: value.image_id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + snapshot_id: value.snapshot_id?, + state: value.state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Disk { + fn from(value: super::Disk) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + device_path: Ok(value.device_path), + id: Ok(value.id), + image_id: Ok(value.image_id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + snapshot_id: Ok(value.snapshot_id), + state: Ok(value.state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk_source: ::std::result::Result, + name: ::std::result::Result, + size: ::std::result::Result, + } + + impl ::std::default::Default for DiskCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk_source: Err("no value supplied for disk_source".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + } + } + } + + impl DiskCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk_source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk_source = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_source: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskCreate { + type Error = super::error::ConversionError; + fn try_from( + value: DiskCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk_source: value.disk_source?, + name: value.name?, + size: value.size?, + }) + } + } + + impl ::std::convert::From for DiskCreate { + fn from(value: super::DiskCreate) -> Self { + Self { + description: Ok(value.description), + disk_source: Ok(value.disk_source), + name: Ok(value.name), + size: Ok(value.size), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskIdentifier { + name: ::std::result::Result, + } + + impl ::std::default::Default for DiskIdentifier { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + } + } + } + + impl DiskIdentifier { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskIdentifier { + type Error = super::error::ConversionError; + fn try_from( + value: DiskIdentifier, + ) -> ::std::result::Result { + Ok(Self { name: value.name? }) + } + } + + impl ::std::convert::From for DiskIdentifier { + fn from(value: super::DiskIdentifier) -> Self { + Self { + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskPath { + disk: ::std::result::Result, + } + + impl ::std::default::Default for DiskPath { + fn default() -> Self { + Self { + disk: Err("no value supplied for disk".to_string()), + } + } + } + + impl DiskPath { + pub fn disk(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskPath { + type Error = super::error::ConversionError; + fn try_from( + value: DiskPath, + ) -> ::std::result::Result { + Ok(Self { disk: value.disk? }) + } + } + + impl ::std::convert::From for DiskPath { + fn from(value: super::DiskPath) -> Self { + Self { + disk: Ok(value.disk), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for DiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl DiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: DiskResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for DiskResultsPage { + fn from(value: super::DiskResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Distribution { + name: ::std::result::Result, + version: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Distribution { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl Distribution { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Distribution { + type Error = super::error::ConversionError; + fn try_from( + value: Distribution, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for Distribution { + fn from(value: super::Distribution) -> Self { + Self { + name: Ok(value.name), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + message: ::std::result::Result<::std::string::String, ::std::string::String>, + request_id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Error { + type Error = super::error::ConversionError; + fn try_from( + value: Error, + ) -> ::std::result::Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl ::std::convert::From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct ExternalIp { + ip: ::std::result::Result<::std::net::IpAddr, ::std::string::String>, + kind: ::std::result::Result, + } + + impl ::std::default::Default for ExternalIp { + fn default() -> Self { + Self { + ip: Err("no value supplied for ip".to_string()), + kind: Err("no value supplied for kind".to_string()), + } + } + } + + impl ExternalIp { + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::IpAddr>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ExternalIp { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIp, + ) -> ::std::result::Result { + Ok(Self { + ip: value.ip?, + kind: value.kind?, + }) + } + } + + impl ::std::convert::From for ExternalIp { + fn from(value: super::ExternalIp) -> Self { + Self { + ip: Ok(value.ip), + kind: Ok(value.kind), + } + } + } + + #[derive(Clone, Debug)] + pub struct ExternalIpResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ExternalIpResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ExternalIpResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ExternalIpResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIpResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ExternalIpResultsPage { + fn from(value: super::ExternalIpResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct FieldSchema { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + source: ::std::result::Result, + ty: ::std::result::Result, + } + + impl ::std::default::Default for FieldSchema { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + ty: Err("no value supplied for ty".to_string()), + } + } + } + + impl FieldSchema { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + pub fn ty(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ty = value + .try_into() + .map_err(|e| format!("error converting supplied value for ty: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::FieldSchema { + type Error = super::error::ConversionError; + fn try_from( + value: FieldSchema, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + source: value.source?, + ty: value.ty?, + }) + } + } + + impl ::std::convert::From for FieldSchema { + fn from(value: super::FieldSchema) -> Self { + Self { + name: Ok(value.name), + source: Ok(value.source), + ty: Ok(value.ty), + } + } + } + + #[derive(Clone, Debug)] + pub struct FleetRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for FleetRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl FleetRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::FleetRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for FleetRolePolicy { + fn from(value: super::FleetRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct FleetRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for FleetRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl FleetRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::FleetRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for FleetRoleRoleAssignment { + fn from(value: super::FleetRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImage { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + digest: + ::std::result::Result<::std::option::Option, ::std::string::String>, + distribution: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + size: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + url: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + version: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for GlobalImage { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + digest: Ok(Default::default()), + distribution: Err("no value supplied for distribution".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + size: Err("no value supplied for size".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + url: Ok(Default::default()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl GlobalImage { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn digest(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.digest = value + .try_into() + .map_err(|e| format!("error converting supplied value for digest: {}", e)); + self + } + pub fn distribution(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.distribution = value.try_into().map_err(|e| { + format!("error converting supplied value for distribution: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImage { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImage, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + digest: value.digest?, + distribution: value.distribution?, + id: value.id?, + name: value.name?, + size: value.size?, + time_created: value.time_created?, + time_modified: value.time_modified?, + url: value.url?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for GlobalImage { + fn from(value: super::GlobalImage) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + digest: Ok(value.digest), + distribution: Ok(value.distribution), + id: Ok(value.id), + name: Ok(value.name), + size: Ok(value.size), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + url: Ok(value.url), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImageCreate { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + distribution: ::std::result::Result, + name: ::std::result::Result, + source: ::std::result::Result, + } + + impl ::std::default::Default for GlobalImageCreate { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + distribution: Err("no value supplied for distribution".to_string()), + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + } + } + } + + impl GlobalImageCreate { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn distribution(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.distribution = value.try_into().map_err(|e| { + format!("error converting supplied value for distribution: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImageCreate { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageCreate, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + distribution: value.distribution?, + name: value.name?, + source: value.source?, + }) + } + } + + impl ::std::convert::From for GlobalImageCreate { + fn from(value: super::GlobalImageCreate) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + distribution: Ok(value.distribution), + name: Ok(value.name), + source: Ok(value.source), + } + } + } + + #[derive(Clone, Debug)] + pub struct GlobalImageResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for GlobalImageResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GlobalImageResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GlobalImageResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for GlobalImageResultsPage { + fn from(value: super::GlobalImageResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Group { + display_name: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + silo_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for Group { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl Group { + pub fn display_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Group { + type Error = super::error::ConversionError; + fn try_from( + value: Group, + ) -> ::std::result::Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + impl ::std::convert::From for Group { + fn from(value: super::Group) -> Self { + Self { + display_name: Ok(value.display_name), + id: Ok(value.id), + silo_id: Ok(value.silo_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct GroupResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for GroupResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl GroupResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::GroupResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: GroupResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for GroupResultsPage { + fn from(value: super::GroupResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Histogramdouble { + bins: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + n_samples: ::std::result::Result, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Histogramdouble { + fn default() -> Self { + Self { + bins: Err("no value supplied for bins".to_string()), + n_samples: Err("no value supplied for n_samples".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl Histogramdouble { + pub fn bins(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.bins = value + .try_into() + .map_err(|e| format!("error converting supplied value for bins: {}", e)); + self + } + pub fn n_samples(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.n_samples = value + .try_into() + .map_err(|e| format!("error converting supplied value for n_samples: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Histogramdouble { + type Error = super::error::ConversionError; + fn try_from( + value: Histogramdouble, + ) -> ::std::result::Result { + Ok(Self { + bins: value.bins?, + n_samples: value.n_samples?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for Histogramdouble { + fn from(value: super::Histogramdouble) -> Self { + Self { + bins: Ok(value.bins), + n_samples: Ok(value.n_samples), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct Histogramint64 { + bins: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + n_samples: ::std::result::Result, + start_time: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Histogramint64 { + fn default() -> Self { + Self { + bins: Err("no value supplied for bins".to_string()), + n_samples: Err("no value supplied for n_samples".to_string()), + start_time: Err("no value supplied for start_time".to_string()), + } + } + } + + impl Histogramint64 { + pub fn bins(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.bins = value + .try_into() + .map_err(|e| format!("error converting supplied value for bins: {}", e)); + self + } + pub fn n_samples(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.n_samples = value + .try_into() + .map_err(|e| format!("error converting supplied value for n_samples: {}", e)); + self + } + pub fn start_time(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.start_time = value + .try_into() + .map_err(|e| format!("error converting supplied value for start_time: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Histogramint64 { + type Error = super::error::ConversionError; + fn try_from( + value: Histogramint64, + ) -> ::std::result::Result { + Ok(Self { + bins: value.bins?, + n_samples: value.n_samples?, + start_time: value.start_time?, + }) + } + } + + impl ::std::convert::From for Histogramint64 { + fn from(value: super::Histogramint64) -> Self { + Self { + bins: Ok(value.bins), + n_samples: Ok(value.n_samples), + start_time: Ok(value.start_time), + } + } + } + + #[derive(Clone, Debug)] + pub struct IdentityProvider { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + provider_type: + ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IdentityProvider { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + provider_type: Err("no value supplied for provider_type".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl IdentityProvider { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn provider_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.provider_type = value.try_into().map_err(|e| { + format!("error converting supplied value for provider_type: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IdentityProvider { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProvider, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + provider_type: value.provider_type?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for IdentityProvider { + fn from(value: super::IdentityProvider) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + provider_type: Ok(value.provider_type), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct IdentityProviderResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IdentityProviderResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IdentityProviderResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IdentityProviderResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProviderResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IdentityProviderResultsPage { + fn from(value: super::IdentityProviderResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Image { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + digest: + ::std::result::Result<::std::option::Option, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + url: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + version: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Image { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + digest: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + url: Ok(Default::default()), + version: Ok(Default::default()), + } + } + } + + impl Image { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn digest(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.digest = value + .try_into() + .map_err(|e| format!("error converting supplied value for digest: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.url = value + .try_into() + .map_err(|e| format!("error converting supplied value for url: {}", e)); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Image { + type Error = super::error::ConversionError; + fn try_from( + value: Image, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + digest: value.digest?, + id: value.id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + time_created: value.time_created?, + time_modified: value.time_modified?, + url: value.url?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for Image { + fn from(value: super::Image) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + digest: Ok(value.digest), + id: Ok(value.id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + url: Ok(value.url), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct ImageCreate { + block_size: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + source: ::std::result::Result, + } + + impl ::std::default::Default for ImageCreate { + fn default() -> Self { + Self { + block_size: Err("no value supplied for block_size".to_string()), + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + source: Err("no value supplied for source".to_string()), + } + } + } + + impl ImageCreate { + pub fn block_size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.block_size = value + .try_into() + .map_err(|e| format!("error converting supplied value for block_size: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.source = value + .try_into() + .map_err(|e| format!("error converting supplied value for source: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ImageCreate { + type Error = super::error::ConversionError; + fn try_from( + value: ImageCreate, + ) -> ::std::result::Result { + Ok(Self { + block_size: value.block_size?, + description: value.description?, + name: value.name?, + source: value.source?, + }) + } + } + + impl ::std::convert::From for ImageCreate { + fn from(value: super::ImageCreate) -> Self { + Self { + block_size: Ok(value.block_size), + description: Ok(value.description), + name: Ok(value.name), + source: Ok(value.source), + } + } + } + + #[derive(Clone, Debug)] + pub struct ImageResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ImageResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ImageResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ImageResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ImageResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ImageResultsPage { + fn from(value: super::ImageResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Instance { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + hostname: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result, + ncpus: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + run_state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_run_state_updated: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Instance { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + hostname: Err("no value supplied for hostname".to_string()), + id: Err("no value supplied for id".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + ncpus: Err("no value supplied for ncpus".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + run_state: Err("no value supplied for run_state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + time_run_state_updated: Err( + "no value supplied for time_run_state_updated".to_string() + ), + } + } + } + + impl Instance { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn hostname(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.hostname = value + .try_into() + .map_err(|e| format!("error converting supplied value for hostname: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn ncpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ncpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for ncpus: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn run_state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.run_state = value + .try_into() + .map_err(|e| format!("error converting supplied value for run_state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn time_run_state_updated(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_run_state_updated = value.try_into().map_err(|e| { + format!( + "error converting supplied value for time_run_state_updated: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Instance { + type Error = super::error::ConversionError; + fn try_from( + value: Instance, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + hostname: value.hostname?, + id: value.id?, + memory: value.memory?, + name: value.name?, + ncpus: value.ncpus?, + project_id: value.project_id?, + run_state: value.run_state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + time_run_state_updated: value.time_run_state_updated?, + }) + } + } + + impl ::std::convert::From for Instance { + fn from(value: super::Instance) -> Self { + Self { + description: Ok(value.description), + hostname: Ok(value.hostname), + id: Ok(value.id), + memory: Ok(value.memory), + name: Ok(value.name), + ncpus: Ok(value.ncpus), + project_id: Ok(value.project_id), + run_state: Ok(value.run_state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + time_run_state_updated: Ok(value.time_run_state_updated), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disks: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + external_ips: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + hostname: ::std::result::Result<::std::string::String, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result, + ncpus: ::std::result::Result, + network_interfaces: ::std::result::Result< + super::InstanceNetworkInterfaceAttachment, + ::std::string::String, + >, + start: ::std::result::Result, + user_data: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for InstanceCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disks: Ok(Default::default()), + external_ips: Ok(Default::default()), + hostname: Err("no value supplied for hostname".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + ncpus: Err("no value supplied for ncpus".to_string()), + network_interfaces: Ok(super::defaults::instance_create_network_interfaces()), + start: Ok(super::defaults::default_bool::()), + user_data: Ok(Default::default()), + } + } + } + + impl InstanceCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn external_ips(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.external_ips = value.try_into().map_err(|e| { + format!("error converting supplied value for external_ips: {}", e) + }); + self + } + pub fn hostname(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.hostname = value + .try_into() + .map_err(|e| format!("error converting supplied value for hostname: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn ncpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ncpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for ncpus: {}", e)); + self + } + pub fn network_interfaces(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.network_interfaces = value.try_into().map_err(|e| { + format!( + "error converting supplied value for network_interfaces: {}", + e + ) + }); + self + } + pub fn start(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.start = value + .try_into() + .map_err(|e| format!("error converting supplied value for start: {}", e)); + self + } + pub fn user_data(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.user_data = value + .try_into() + .map_err(|e| format!("error converting supplied value for user_data: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceCreate { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disks: value.disks?, + external_ips: value.external_ips?, + hostname: value.hostname?, + memory: value.memory?, + name: value.name?, + ncpus: value.ncpus?, + network_interfaces: value.network_interfaces?, + start: value.start?, + user_data: value.user_data?, + }) + } + } + + impl ::std::convert::From for InstanceCreate { + fn from(value: super::InstanceCreate) -> Self { + Self { + description: Ok(value.description), + disks: Ok(value.disks), + external_ips: Ok(value.external_ips), + hostname: Ok(value.hostname), + memory: Ok(value.memory), + name: Ok(value.name), + ncpus: Ok(value.ncpus), + network_interfaces: Ok(value.network_interfaces), + start: Ok(value.start), + user_data: Ok(value.user_data), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrate { + dst_sled_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrate { + fn default() -> Self { + Self { + dst_sled_id: Err("no value supplied for dst_sled_id".to_string()), + } + } + } + + impl InstanceMigrate { + pub fn dst_sled_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.dst_sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for dst_sled_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceMigrate { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrate, + ) -> ::std::result::Result { + Ok(Self { + dst_sled_id: value.dst_sled_id?, + }) + } + } + + impl ::std::convert::From for InstanceMigrate { + fn from(value: super::InstanceMigrate) -> Self { + Self { + dst_sled_id: Ok(value.dst_sled_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for InstanceResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl InstanceResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for InstanceResultsPage { + fn from(value: super::InstanceResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceSerialConsoleData { + data: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + last_byte_offset: ::std::result::Result, + } + + impl ::std::default::Default for InstanceSerialConsoleData { + fn default() -> Self { + Self { + data: Err("no value supplied for data".to_string()), + last_byte_offset: Err("no value supplied for last_byte_offset".to_string()), + } + } + } + + impl InstanceSerialConsoleData { + pub fn data(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.data = value + .try_into() + .map_err(|e| format!("error converting supplied value for data: {}", e)); + self + } + pub fn last_byte_offset(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.last_byte_offset = value.try_into().map_err(|e| { + format!( + "error converting supplied value for last_byte_offset: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceSerialConsoleData { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceSerialConsoleData, + ) -> ::std::result::Result { + Ok(Self { + data: value.data?, + last_byte_offset: value.last_byte_offset?, + }) + } + } + + impl ::std::convert::From for InstanceSerialConsoleData { + fn from(value: super::InstanceSerialConsoleData) -> Self { + Self { + data: Ok(value.data), + last_byte_offset: Ok(value.last_byte_offset), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPool { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPool { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl IpPool { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IpPool { + type Error = super::error::ConversionError; + fn try_from( + value: IpPool, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for IpPool { + fn from(value: super::IpPool) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for IpPoolCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl IpPoolCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolCreate { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for IpPoolCreate { + fn from(value: super::IpPoolCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolRange { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + range: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolRange { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + range: Err("no value supplied for range".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + } + } + } + + impl IpPoolRange { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.range = value + .try_into() + .map_err(|e| format!("error converting supplied value for range: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolRange { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRange, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + range: value.range?, + time_created: value.time_created?, + }) + } + } + + impl ::std::convert::From for IpPoolRange { + fn from(value: super::IpPoolRange) -> Self { + Self { + id: Ok(value.id), + range: Ok(value.range), + time_created: Ok(value.time_created), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolRangeResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolRangeResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IpPoolRangeResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolRangeResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRangeResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IpPoolRangeResultsPage { + fn from(value: super::IpPoolRangeResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for IpPoolResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl IpPoolResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for IpPoolResultsPage { + fn from(value: super::IpPoolResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct IpPoolUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for IpPoolUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl IpPoolUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::IpPoolUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for IpPoolUpdate { + fn from(value: super::IpPoolUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Ipv4Range { + first: ::std::result::Result<::std::net::Ipv4Addr, ::std::string::String>, + last: ::std::result::Result<::std::net::Ipv4Addr, ::std::string::String>, + } + + impl ::std::default::Default for Ipv4Range { + fn default() -> Self { + Self { + first: Err("no value supplied for first".to_string()), + last: Err("no value supplied for last".to_string()), + } + } + } + + impl Ipv4Range { + pub fn first(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv4Addr>, + T::Error: ::std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn last(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv4Addr>, + T::Error: ::std::fmt::Display, + { + self.last = value + .try_into() + .map_err(|e| format!("error converting supplied value for last: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Ipv4Range { + type Error = super::error::ConversionError; + fn try_from( + value: Ipv4Range, + ) -> ::std::result::Result { + Ok(Self { + first: value.first?, + last: value.last?, + }) + } + } + + impl ::std::convert::From for Ipv4Range { + fn from(value: super::Ipv4Range) -> Self { + Self { + first: Ok(value.first), + last: Ok(value.last), + } + } + } + + #[derive(Clone, Debug)] + pub struct Ipv6Range { + first: ::std::result::Result<::std::net::Ipv6Addr, ::std::string::String>, + last: ::std::result::Result<::std::net::Ipv6Addr, ::std::string::String>, + } + + impl ::std::default::Default for Ipv6Range { + fn default() -> Self { + Self { + first: Err("no value supplied for first".to_string()), + last: Err("no value supplied for last".to_string()), + } + } + } + + impl Ipv6Range { + pub fn first(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv6Addr>, + T::Error: ::std::fmt::Display, + { + self.first = value + .try_into() + .map_err(|e| format!("error converting supplied value for first: {}", e)); + self + } + pub fn last(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::Ipv6Addr>, + T::Error: ::std::fmt::Display, + { + self.last = value + .try_into() + .map_err(|e| format!("error converting supplied value for last: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Ipv6Range { + type Error = super::error::ConversionError; + fn try_from( + value: Ipv6Range, + ) -> ::std::result::Result { + Ok(Self { + first: value.first?, + last: value.last?, + }) + } + } + + impl ::std::convert::From for Ipv6Range { + fn from(value: super::Ipv6Range) -> Self { + Self { + first: Ok(value.first), + last: Ok(value.last), + } + } + } + + #[derive(Clone, Debug)] + pub struct Measurement { + datum: ::std::result::Result, + timestamp: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Measurement { + fn default() -> Self { + Self { + datum: Err("no value supplied for datum".to_string()), + timestamp: Err("no value supplied for timestamp".to_string()), + } + } + } + + impl Measurement { + pub fn datum(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.datum = value + .try_into() + .map_err(|e| format!("error converting supplied value for datum: {}", e)); + self + } + pub fn timestamp(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.timestamp = value + .try_into() + .map_err(|e| format!("error converting supplied value for timestamp: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Measurement { + type Error = super::error::ConversionError; + fn try_from( + value: Measurement, + ) -> ::std::result::Result { + Ok(Self { + datum: value.datum?, + timestamp: value.timestamp?, + }) + } + } + + impl ::std::convert::From for Measurement { + fn from(value: super::Measurement) -> Self { + Self { + datum: Ok(value.datum), + timestamp: Ok(value.timestamp), + } + } + } + + #[derive(Clone, Debug)] + pub struct MeasurementResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for MeasurementResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl MeasurementResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::MeasurementResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: MeasurementResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for MeasurementResultsPage { + fn from(value: super::MeasurementResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterface { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + instance_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ip: ::std::result::Result<::std::net::IpAddr, ::std::string::String>, + mac: ::std::result::Result, + name: ::std::result::Result, + primary: ::std::result::Result, + subnet_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for NetworkInterface { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + instance_id: Err("no value supplied for instance_id".to_string()), + ip: Err("no value supplied for ip".to_string()), + mac: Err("no value supplied for mac".to_string()), + name: Err("no value supplied for name".to_string()), + primary: Err("no value supplied for primary".to_string()), + subnet_id: Err("no value supplied for subnet_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl NetworkInterface { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn instance_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.instance_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance_id: {}", e)); + self + } + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::net::IpAddr>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn mac(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.mac = value + .try_into() + .map_err(|e| format!("error converting supplied value for mac: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn primary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } + pub fn subnet_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.subnet_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for subnet_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterface { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterface, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + instance_id: value.instance_id?, + ip: value.ip?, + mac: value.mac?, + name: value.name?, + primary: value.primary?, + subnet_id: value.subnet_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for NetworkInterface { + fn from(value: super::NetworkInterface) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + instance_id: Ok(value.instance_id), + ip: Ok(value.ip), + mac: Ok(value.mac), + name: Ok(value.name), + primary: Ok(value.primary), + subnet_id: Ok(value.subnet_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + ip: ::std::result::Result< + ::std::option::Option<::std::net::IpAddr>, + ::std::string::String, + >, + name: ::std::result::Result, + subnet_name: ::std::result::Result, + vpc_name: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + ip: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + subnet_name: Err("no value supplied for subnet_name".to_string()), + vpc_name: Err("no value supplied for vpc_name".to_string()), + } + } + } + + impl NetworkInterfaceCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn ip(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::net::IpAddr>>, + T::Error: ::std::fmt::Display, + { + self.ip = value + .try_into() + .map_err(|e| format!("error converting supplied value for ip: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn subnet_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.subnet_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for subnet_name: {}", e)); + self + } + pub fn vpc_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.vpc_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceCreate { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + ip: value.ip?, + name: value.name?, + subnet_name: value.subnet_name?, + vpc_name: value.vpc_name?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceCreate { + fn from(value: super::NetworkInterfaceCreate) -> Self { + Self { + description: Ok(value.description), + ip: Ok(value.ip), + name: Ok(value.name), + subnet_name: Ok(value.subnet_name), + vpc_name: Ok(value.vpc_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for NetworkInterfaceResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl NetworkInterfaceResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceResultsPage { + fn from(value: super::NetworkInterfaceResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + primary: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + primary: Ok(Default::default()), + } + } + } + + impl NetworkInterfaceUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn primary(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.primary = value + .try_into() + .map_err(|e| format!("error converting supplied value for primary: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + primary: value.primary?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceUpdate { + fn from(value: super::NetworkInterfaceUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + primary: Ok(value.primary), + } + } + } + + #[derive(Clone, Debug)] + pub struct Organization { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Organization { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Organization { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Organization { + type Error = super::error::ConversionError; + fn try_from( + value: Organization, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Organization { + fn from(value: super::Organization) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for OrganizationCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl OrganizationCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationCreate { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for OrganizationCreate { + fn from(value: super::OrganizationCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for OrganizationResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl OrganizationResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for OrganizationResultsPage { + fn from(value: super::OrganizationResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for OrganizationRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl OrganizationRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for OrganizationRolePolicy { + fn from(value: super::OrganizationRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for OrganizationRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl OrganizationRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::OrganizationRoleRoleAssignment + { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From + for OrganizationRoleRoleAssignment + { + fn from(value: super::OrganizationRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct OrganizationUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for OrganizationUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl OrganizationUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::OrganizationUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for OrganizationUpdate { + fn from(value: super::OrganizationUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct PhysicalDisk { + disk_type: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + model: ::std::result::Result<::std::string::String, ::std::string::String>, + serial: ::std::result::Result<::std::string::String, ::std::string::String>, + sled_id: + ::std::result::Result<::std::option::Option<::uuid::Uuid>, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vendor: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for PhysicalDisk { + fn default() -> Self { + Self { + disk_type: Err("no value supplied for disk_type".to_string()), + id: Err("no value supplied for id".to_string()), + model: Err("no value supplied for model".to_string()), + serial: Err("no value supplied for serial".to_string()), + sled_id: Ok(Default::default()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vendor: Err("no value supplied for vendor".to_string()), + } + } + } + + impl PhysicalDisk { + pub fn disk_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_type: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn model(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.model = value + .try_into() + .map_err(|e| format!("error converting supplied value for model: {}", e)); + self + } + pub fn serial(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.serial = value + .try_into() + .map_err(|e| format!("error converting supplied value for serial: {}", e)); + self + } + pub fn sled_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::uuid::Uuid>>, + T::Error: ::std::fmt::Display, + { + self.sled_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for sled_id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vendor(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.vendor = value + .try_into() + .map_err(|e| format!("error converting supplied value for vendor: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PhysicalDisk { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDisk, + ) -> ::std::result::Result { + Ok(Self { + disk_type: value.disk_type?, + id: value.id?, + model: value.model?, + serial: value.serial?, + sled_id: value.sled_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vendor: value.vendor?, + }) + } + } + + impl ::std::convert::From for PhysicalDisk { + fn from(value: super::PhysicalDisk) -> Self { + Self { + disk_type: Ok(value.disk_type), + id: Ok(value.id), + model: Ok(value.model), + serial: Ok(value.serial), + sled_id: Ok(value.sled_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vendor: Ok(value.vendor), + } + } + } + + #[derive(Clone, Debug)] + pub struct PhysicalDiskResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for PhysicalDiskResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl PhysicalDiskResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::PhysicalDiskResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDiskResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for PhysicalDiskResultsPage { + fn from(value: super::PhysicalDiskResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Project { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + organization_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Project { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + organization_id: Err("no value supplied for organization_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Project { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn organization_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.organization_id = value.try_into().map_err(|e| { + format!("error converting supplied value for organization_id: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Project { + type Error = super::error::ConversionError; + fn try_from( + value: Project, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + organization_id: value.organization_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Project { + fn from(value: super::Project) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + organization_id: Ok(value.organization_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for ProjectCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl ProjectCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectCreate { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for ProjectCreate { + fn from(value: super::ProjectCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for ProjectResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl ProjectResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for ProjectResultsPage { + fn from(value: super::ProjectResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for ProjectRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl ProjectRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for ProjectRolePolicy { + fn from(value: super::ProjectRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for ProjectRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl ProjectRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for ProjectRoleRoleAssignment { + fn from(value: super::ProjectRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct ProjectUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for ProjectUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl ProjectUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::ProjectUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for ProjectUpdate { + fn from(value: super::ProjectUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Rack { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Rack { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Rack { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Rack { + type Error = super::error::ConversionError; + fn try_from(value: Rack) -> ::std::result::Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Rack { + fn from(value: super::Rack) -> Self { + Self { + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct RackResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RackResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RackResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RackResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RackResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RackResultsPage { + fn from(value: super::RackResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Role { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for Role { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl Role { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Role { + type Error = super::error::ConversionError; + fn try_from(value: Role) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for Role { + fn from(value: super::Role) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct RoleResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RoleResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RoleResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RoleResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RoleResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RoleResultsPage { + fn from(value: super::RoleResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRoute { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + destination: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + kind: ::std::result::Result, + name: ::std::result::Result, + target: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_router_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for RouterRoute { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + destination: Err("no value supplied for destination".to_string()), + id: Err("no value supplied for id".to_string()), + kind: Err("no value supplied for kind".to_string()), + name: Err("no value supplied for name".to_string()), + target: Err("no value supplied for target".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_router_id: Err("no value supplied for vpc_router_id".to_string()), + } + } + } + + impl RouterRoute { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_router_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_router_id = value.try_into().map_err(|e| { + format!("error converting supplied value for vpc_router_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRoute { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRoute, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + id: value.id?, + kind: value.kind?, + name: value.name?, + target: value.target?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_router_id: value.vpc_router_id?, + }) + } + } + + impl ::std::convert::From for RouterRoute { + fn from(value: super::RouterRoute) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + id: Ok(value.id), + kind: Ok(value.kind), + name: Ok(value.name), + target: Ok(value.target), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_router_id: Ok(value.vpc_router_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteCreateParams { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + destination: ::std::result::Result, + name: ::std::result::Result, + target: ::std::result::Result, + } + + impl ::std::default::Default for RouterRouteCreateParams { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + destination: Err("no value supplied for destination".to_string()), + name: Err("no value supplied for name".to_string()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl RouterRouteCreateParams { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteCreateParams { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteCreateParams, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + name: value.name?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for RouterRouteCreateParams { + fn from(value: super::RouterRouteCreateParams) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + name: Ok(value.name), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for RouterRouteResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl RouterRouteResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for RouterRouteResultsPage { + fn from(value: super::RouterRouteResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct RouterRouteUpdateParams { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + destination: ::std::result::Result, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + target: ::std::result::Result, + } + + impl ::std::default::Default for RouterRouteUpdateParams { + fn default() -> Self { + Self { + description: Ok(Default::default()), + destination: Err("no value supplied for destination".to_string()), + name: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl RouterRouteUpdateParams { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn destination(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.destination = value + .try_into() + .map_err(|e| format!("error converting supplied value for destination: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::RouterRouteUpdateParams { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteUpdateParams, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + destination: value.destination?, + name: value.name?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for RouterRouteUpdateParams { + fn from(value: super::RouterRouteUpdateParams) -> Self { + Self { + description: Ok(value.description), + destination: Ok(value.destination), + name: Ok(value.name), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct Saga { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + state: ::std::result::Result, + } + + impl ::std::default::Default for Saga { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Saga { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Saga { + type Error = super::error::ConversionError; + fn try_from(value: Saga) -> ::std::result::Result { + Ok(Self { + id: value.id?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Saga { + fn from(value: super::Saga) -> Self { + Self { + id: Ok(value.id), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct SagaResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SagaResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SagaResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SagaResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SagaResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SagaResultsPage { + fn from(value: super::SagaResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SamlIdentityProvider { + acs_url: ::std::result::Result<::std::string::String, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + idp_entity_id: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + public_cert: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + slo_url: ::std::result::Result<::std::string::String, ::std::string::String>, + sp_client_id: ::std::result::Result<::std::string::String, ::std::string::String>, + technical_contact_email: + ::std::result::Result<::std::string::String, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SamlIdentityProvider { + fn default() -> Self { + Self { + acs_url: Err("no value supplied for acs_url".to_string()), + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), + name: Err("no value supplied for name".to_string()), + public_cert: Ok(Default::default()), + slo_url: Err("no value supplied for slo_url".to_string()), + sp_client_id: Err("no value supplied for sp_client_id".to_string()), + technical_contact_email: Err( + "no value supplied for technical_contact_email".to_string() + ), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl SamlIdentityProvider { + pub fn acs_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.acs_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for acs_url: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn idp_entity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.idp_entity_id = value.try_into().map_err(|e| { + format!("error converting supplied value for idp_entity_id: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_cert(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.public_cert = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_cert: {}", e)); + self + } + pub fn slo_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.slo_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for slo_url: {}", e)); + self + } + pub fn sp_client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.sp_client_id = value.try_into().map_err(|e| { + format!("error converting supplied value for sp_client_id: {}", e) + }); + self + } + pub fn technical_contact_email(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.technical_contact_email = value.try_into().map_err(|e| { + format!( + "error converting supplied value for technical_contact_email: {}", + e + ) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SamlIdentityProvider { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProvider, + ) -> ::std::result::Result { + Ok(Self { + acs_url: value.acs_url?, + description: value.description?, + id: value.id?, + idp_entity_id: value.idp_entity_id?, + name: value.name?, + public_cert: value.public_cert?, + slo_url: value.slo_url?, + sp_client_id: value.sp_client_id?, + technical_contact_email: value.technical_contact_email?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for SamlIdentityProvider { + fn from(value: super::SamlIdentityProvider) -> Self { + Self { + acs_url: Ok(value.acs_url), + description: Ok(value.description), + id: Ok(value.id), + idp_entity_id: Ok(value.idp_entity_id), + name: Ok(value.name), + public_cert: Ok(value.public_cert), + slo_url: Ok(value.slo_url), + sp_client_id: Ok(value.sp_client_id), + technical_contact_email: Ok(value.technical_contact_email), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SamlIdentityProviderCreate { + acs_url: ::std::result::Result<::std::string::String, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + group_attribute_name: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + idp_entity_id: ::std::result::Result<::std::string::String, ::std::string::String>, + idp_metadata_source: + ::std::result::Result, + name: ::std::result::Result, + signing_keypair: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + slo_url: ::std::result::Result<::std::string::String, ::std::string::String>, + sp_client_id: ::std::result::Result<::std::string::String, ::std::string::String>, + technical_contact_email: + ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SamlIdentityProviderCreate { + fn default() -> Self { + Self { + acs_url: Err("no value supplied for acs_url".to_string()), + description: Err("no value supplied for description".to_string()), + group_attribute_name: Ok(Default::default()), + idp_entity_id: Err("no value supplied for idp_entity_id".to_string()), + idp_metadata_source: Err( + "no value supplied for idp_metadata_source".to_string() + ), + name: Err("no value supplied for name".to_string()), + signing_keypair: Ok(Default::default()), + slo_url: Err("no value supplied for slo_url".to_string()), + sp_client_id: Err("no value supplied for sp_client_id".to_string()), + technical_contact_email: Err( + "no value supplied for technical_contact_email".to_string() + ), + } + } + } + + impl SamlIdentityProviderCreate { + pub fn acs_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.acs_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for acs_url: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn group_attribute_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.group_attribute_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for group_attribute_name: {}", + e + ) + }); + self + } + pub fn idp_entity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.idp_entity_id = value.try_into().map_err(|e| { + format!("error converting supplied value for idp_entity_id: {}", e) + }); + self + } + pub fn idp_metadata_source(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.idp_metadata_source = value.try_into().map_err(|e| { + format!( + "error converting supplied value for idp_metadata_source: {}", + e + ) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn signing_keypair(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.signing_keypair = value.try_into().map_err(|e| { + format!("error converting supplied value for signing_keypair: {}", e) + }); + self + } + pub fn slo_url(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.slo_url = value + .try_into() + .map_err(|e| format!("error converting supplied value for slo_url: {}", e)); + self + } + pub fn sp_client_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.sp_client_id = value.try_into().map_err(|e| { + format!("error converting supplied value for sp_client_id: {}", e) + }); + self + } + pub fn technical_contact_email(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.technical_contact_email = value.try_into().map_err(|e| { + format!( + "error converting supplied value for technical_contact_email: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SamlIdentityProviderCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProviderCreate, + ) -> ::std::result::Result { + Ok(Self { + acs_url: value.acs_url?, + description: value.description?, + group_attribute_name: value.group_attribute_name?, + idp_entity_id: value.idp_entity_id?, + idp_metadata_source: value.idp_metadata_source?, + name: value.name?, + signing_keypair: value.signing_keypair?, + slo_url: value.slo_url?, + sp_client_id: value.sp_client_id?, + technical_contact_email: value.technical_contact_email?, + }) + } + } + + impl ::std::convert::From for SamlIdentityProviderCreate { + fn from(value: super::SamlIdentityProviderCreate) -> Self { + Self { + acs_url: Ok(value.acs_url), + description: Ok(value.description), + group_attribute_name: Ok(value.group_attribute_name), + idp_entity_id: Ok(value.idp_entity_id), + idp_metadata_source: Ok(value.idp_metadata_source), + name: Ok(value.name), + signing_keypair: Ok(value.signing_keypair), + slo_url: Ok(value.slo_url), + sp_client_id: Ok(value.sp_client_id), + technical_contact_email: Ok(value.technical_contact_email), + } + } + } + + #[derive(Clone, Debug)] + pub struct Silo { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + discoverable: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_mode: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Silo { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + discoverable: Err("no value supplied for discoverable".to_string()), + id: Err("no value supplied for id".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Silo { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn discoverable(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.discoverable = value.try_into().map_err(|e| { + format!("error converting supplied value for discoverable: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn identity_mode(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Silo { + type Error = super::error::ConversionError; + fn try_from(value: Silo) -> ::std::result::Result { + Ok(Self { + description: value.description?, + discoverable: value.discoverable?, + id: value.id?, + identity_mode: value.identity_mode?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Silo { + fn from(value: super::Silo) -> Self { + Self { + description: Ok(value.description), + discoverable: Ok(value.discoverable), + id: Ok(value.id), + identity_mode: Ok(value.identity_mode), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloCreate { + admin_group_name: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + discoverable: ::std::result::Result, + identity_mode: ::std::result::Result, + name: ::std::result::Result, + } + + impl ::std::default::Default for SiloCreate { + fn default() -> Self { + Self { + admin_group_name: Ok(Default::default()), + description: Err("no value supplied for description".to_string()), + discoverable: Err("no value supplied for discoverable".to_string()), + identity_mode: Err("no value supplied for identity_mode".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl SiloCreate { + pub fn admin_group_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.admin_group_name = value.try_into().map_err(|e| { + format!( + "error converting supplied value for admin_group_name: {}", + e + ) + }); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn discoverable(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.discoverable = value.try_into().map_err(|e| { + format!("error converting supplied value for discoverable: {}", e) + }); + self + } + pub fn identity_mode(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_mode = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_mode: {}", e) + }); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SiloCreate, + ) -> ::std::result::Result { + Ok(Self { + admin_group_name: value.admin_group_name?, + description: value.description?, + discoverable: value.discoverable?, + identity_mode: value.identity_mode?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for SiloCreate { + fn from(value: super::SiloCreate) -> Self { + Self { + admin_group_name: Ok(value.admin_group_name), + description: Ok(value.description), + discoverable: Ok(value.discoverable), + identity_mode: Ok(value.identity_mode), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SiloResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SiloResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SiloResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SiloResultsPage { + fn from(value: super::SiloResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloRolePolicy { + role_assignments: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for SiloRolePolicy { + fn default() -> Self { + Self { + role_assignments: Err("no value supplied for role_assignments".to_string()), + } + } + } + + impl SiloRolePolicy { + pub fn role_assignments(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.role_assignments = value.try_into().map_err(|e| { + format!( + "error converting supplied value for role_assignments: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SiloRolePolicy { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRolePolicy, + ) -> ::std::result::Result { + Ok(Self { + role_assignments: value.role_assignments?, + }) + } + } + + impl ::std::convert::From for SiloRolePolicy { + fn from(value: super::SiloRolePolicy) -> Self { + Self { + role_assignments: Ok(value.role_assignments), + } + } + } + + #[derive(Clone, Debug)] + pub struct SiloRoleRoleAssignment { + identity_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + identity_type: ::std::result::Result, + role_name: ::std::result::Result, + } + + impl ::std::default::Default for SiloRoleRoleAssignment { + fn default() -> Self { + Self { + identity_id: Err("no value supplied for identity_id".to_string()), + identity_type: Err("no value supplied for identity_type".to_string()), + role_name: Err("no value supplied for role_name".to_string()), + } + } + } + + impl SiloRoleRoleAssignment { + pub fn identity_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.identity_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for identity_id: {}", e)); + self + } + pub fn identity_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.identity_type = value.try_into().map_err(|e| { + format!("error converting supplied value for identity_type: {}", e) + }); + self + } + pub fn role_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.role_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for role_name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SiloRoleRoleAssignment { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRoleRoleAssignment, + ) -> ::std::result::Result { + Ok(Self { + identity_id: value.identity_id?, + identity_type: value.identity_type?, + role_name: value.role_name?, + }) + } + } + + impl ::std::convert::From for SiloRoleRoleAssignment { + fn from(value: super::SiloRoleRoleAssignment) -> Self { + Self { + identity_id: Ok(value.identity_id), + identity_type: Ok(value.identity_type), + role_name: Ok(value.role_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct Sled { + baseboard: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + service_address: ::std::result::Result<::std::string::String, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Sled { + fn default() -> Self { + Self { + baseboard: Err("no value supplied for baseboard".to_string()), + id: Err("no value supplied for id".to_string()), + service_address: Err("no value supplied for service_address".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Sled { + pub fn baseboard(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.baseboard = value + .try_into() + .map_err(|e| format!("error converting supplied value for baseboard: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn service_address(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.service_address = value.try_into().map_err(|e| { + format!("error converting supplied value for service_address: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Sled { + type Error = super::error::ConversionError; + fn try_from(value: Sled) -> ::std::result::Result { + Ok(Self { + baseboard: value.baseboard?, + id: value.id?, + service_address: value.service_address?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Sled { + fn from(value: super::Sled) -> Self { + Self { + baseboard: Ok(value.baseboard), + id: Ok(value.id), + service_address: Ok(value.service_address), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SledResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SledResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SledResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SledResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SledResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SledResultsPage { + fn from(value: super::SledResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct Snapshot { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + size: ::std::result::Result, + state: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Snapshot { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk_id: Err("no value supplied for disk_id".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + size: Err("no value supplied for size".to_string()), + state: Err("no value supplied for state".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Snapshot { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.disk_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn size(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.size = value + .try_into() + .map_err(|e| format!("error converting supplied value for size: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Snapshot { + type Error = super::error::ConversionError; + fn try_from( + value: Snapshot, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk_id: value.disk_id?, + id: value.id?, + name: value.name?, + project_id: value.project_id?, + size: value.size?, + state: value.state?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Snapshot { + fn from(value: super::Snapshot) -> Self { + Self { + description: Ok(value.description), + disk_id: Ok(value.disk_id), + id: Ok(value.id), + name: Ok(value.name), + project_id: Ok(value.project_id), + size: Ok(value.size), + state: Ok(value.state), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SnapshotCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + disk: ::std::result::Result, + name: ::std::result::Result, + } + + impl ::std::default::Default for SnapshotCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + disk: Err("no value supplied for disk".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl SnapshotCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn disk(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.disk = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SnapshotCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SnapshotCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + disk: value.disk?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for SnapshotCreate { + fn from(value: super::SnapshotCreate) -> Self { + Self { + description: Ok(value.description), + disk: Ok(value.disk), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct SnapshotResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SnapshotResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SnapshotResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SnapshotResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SnapshotResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SnapshotResultsPage { + fn from(value: super::SnapshotResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SpoofLoginBody { + username: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SpoofLoginBody { + fn default() -> Self { + Self { + username: Err("no value supplied for username".to_string()), + } + } + } + + impl SpoofLoginBody { + pub fn username(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SpoofLoginBody { + type Error = super::error::ConversionError; + fn try_from( + value: SpoofLoginBody, + ) -> ::std::result::Result { + Ok(Self { + username: value.username?, + }) + } + } + + impl ::std::convert::From for SpoofLoginBody { + fn from(value: super::SpoofLoginBody) -> Self { + Self { + username: Ok(value.username), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKey { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + public_key: ::std::result::Result<::std::string::String, ::std::string::String>, + silo_user_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SshKey { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + public_key: Err("no value supplied for public_key".to_string()), + silo_user_id: Err("no value supplied for silo_user_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl SshKey { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_key: {}", e)); + self + } + pub fn silo_user_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_user_id = value.try_into().map_err(|e| { + format!("error converting supplied value for silo_user_id: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SshKey { + type Error = super::error::ConversionError; + fn try_from( + value: SshKey, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + public_key: value.public_key?, + silo_user_id: value.silo_user_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for SshKey { + fn from(value: super::SshKey) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + public_key: Ok(value.public_key), + silo_user_id: Ok(value.silo_user_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKeyCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + public_key: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for SshKeyCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + public_key: Err("no value supplied for public_key".to_string()), + } + } + } + + impl SshKeyCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn public_key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.public_key = value + .try_into() + .map_err(|e| format!("error converting supplied value for public_key: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SshKeyCreate { + type Error = super::error::ConversionError; + fn try_from( + value: SshKeyCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + public_key: value.public_key?, + }) + } + } + + impl ::std::convert::From for SshKeyCreate { + fn from(value: super::SshKeyCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + public_key: Ok(value.public_key), + } + } + } + + #[derive(Clone, Debug)] + pub struct SshKeyResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SshKeyResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SshKeyResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SshKeyResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SshKeyResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SshKeyResultsPage { + fn from(value: super::SshKeyResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdate { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for SystemUpdate { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdate { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdate, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for SystemUpdate { + fn from(value: super::SystemUpdate) -> Self { + Self { + id: Ok(value.id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdateResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for SystemUpdateResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl SystemUpdateResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdateResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for SystemUpdateResultsPage { + fn from(value: super::SystemUpdateResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemUpdateStart { + version: ::std::result::Result, + } + + impl ::std::default::Default for SystemUpdateStart { + fn default() -> Self { + Self { + version: Err("no value supplied for version".to_string()), + } + } + } + + impl SystemUpdateStart { + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::SystemUpdateStart { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateStart, + ) -> ::std::result::Result { + Ok(Self { + version: value.version?, + }) + } + } + + impl ::std::convert::From for SystemUpdateStart { + fn from(value: super::SystemUpdateStart) -> Self { + Self { + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct SystemVersion { + status: ::std::result::Result, + version_range: ::std::result::Result, + } + + impl ::std::default::Default for SystemVersion { + fn default() -> Self { + Self { + status: Err("no value supplied for status".to_string()), + version_range: Err("no value supplied for version_range".to_string()), + } + } + } + + impl SystemVersion { + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn version_range(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version_range = value.try_into().map_err(|e| { + format!("error converting supplied value for version_range: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::SystemVersion { + type Error = super::error::ConversionError; + fn try_from( + value: SystemVersion, + ) -> ::std::result::Result { + Ok(Self { + status: value.status?, + version_range: value.version_range?, + }) + } + } + + impl ::std::convert::From for SystemVersion { + fn from(value: super::SystemVersion) -> Self { + Self { + status: Ok(value.status), + version_range: Ok(value.version_range), + } + } + } + + #[derive(Clone, Debug)] + pub struct TimeseriesSchema { + created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + datum_type: ::std::result::Result, + field_schema: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + timeseries_name: ::std::result::Result, + } + + impl ::std::default::Default for TimeseriesSchema { + fn default() -> Self { + Self { + created: Err("no value supplied for created".to_string()), + datum_type: Err("no value supplied for datum_type".to_string()), + field_schema: Err("no value supplied for field_schema".to_string()), + timeseries_name: Err("no value supplied for timeseries_name".to_string()), + } + } + } + + impl TimeseriesSchema { + pub fn created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.created = value + .try_into() + .map_err(|e| format!("error converting supplied value for created: {}", e)); + self + } + pub fn datum_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.datum_type = value + .try_into() + .map_err(|e| format!("error converting supplied value for datum_type: {}", e)); + self + } + pub fn field_schema(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.field_schema = value.try_into().map_err(|e| { + format!("error converting supplied value for field_schema: {}", e) + }); + self + } + pub fn timeseries_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.timeseries_name = value.try_into().map_err(|e| { + format!("error converting supplied value for timeseries_name: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::TimeseriesSchema { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchema, + ) -> ::std::result::Result { + Ok(Self { + created: value.created?, + datum_type: value.datum_type?, + field_schema: value.field_schema?, + timeseries_name: value.timeseries_name?, + }) + } + } + + impl ::std::convert::From for TimeseriesSchema { + fn from(value: super::TimeseriesSchema) -> Self { + Self { + created: Ok(value.created), + datum_type: Ok(value.datum_type), + field_schema: Ok(value.field_schema), + timeseries_name: Ok(value.timeseries_name), + } + } + } + + #[derive(Clone, Debug)] + pub struct TimeseriesSchemaResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for TimeseriesSchemaResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl TimeseriesSchemaResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::TimeseriesSchemaResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchemaResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for TimeseriesSchemaResultsPage { + fn from(value: super::TimeseriesSchemaResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateDeployment { + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + status: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for UpdateDeployment { + fn default() -> Self { + Self { + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateDeployment { + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateDeployment { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeployment, + ) -> ::std::result::Result { + Ok(Self { + id: value.id?, + status: value.status?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for UpdateDeployment { + fn from(value: super::UpdateDeployment) -> Self { + Self { + id: Ok(value.id), + status: Ok(value.status), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateDeploymentResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UpdateDeploymentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateDeploymentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateDeploymentResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeploymentResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UpdateDeploymentResultsPage { + fn from(value: super::UpdateDeploymentResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateableComponent { + component_type: + ::std::result::Result, + device_id: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + status: ::std::result::Result, + system_version: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + version: ::std::result::Result, + } + + impl ::std::default::Default for UpdateableComponent { + fn default() -> Self { + Self { + component_type: Err("no value supplied for component_type".to_string()), + device_id: Err("no value supplied for device_id".to_string()), + id: Err("no value supplied for id".to_string()), + status: Err("no value supplied for status".to_string()), + system_version: Err("no value supplied for system_version".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + version: Err("no value supplied for version".to_string()), + } + } + } + + impl UpdateableComponent { + pub fn component_type(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.component_type = value.try_into().map_err(|e| { + format!("error converting supplied value for component_type: {}", e) + }); + self + } + pub fn device_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for device_id: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn system_version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.system_version = value.try_into().map_err(|e| { + format!("error converting supplied value for system_version: {}", e) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn version(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.version = value + .try_into() + .map_err(|e| format!("error converting supplied value for version: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UpdateableComponent { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponent, + ) -> ::std::result::Result { + Ok(Self { + component_type: value.component_type?, + device_id: value.device_id?, + id: value.id?, + status: value.status?, + system_version: value.system_version?, + time_created: value.time_created?, + time_modified: value.time_modified?, + version: value.version?, + }) + } + } + + impl ::std::convert::From for UpdateableComponent { + fn from(value: super::UpdateableComponent) -> Self { + Self { + component_type: Ok(value.component_type), + device_id: Ok(value.device_id), + id: Ok(value.id), + status: Ok(value.status), + system_version: Ok(value.system_version), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + version: Ok(value.version), + } + } + } + + #[derive(Clone, Debug)] + pub struct UpdateableComponentResultsPage { + items: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UpdateableComponentResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UpdateableComponentResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::UpdateableComponentResultsPage + { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponentResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From + for UpdateableComponentResultsPage + { + fn from(value: super::UpdateableComponentResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct User { + display_name: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + silo_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for User { + fn default() -> Self { + Self { + display_name: Err("no value supplied for display_name".to_string()), + id: Err("no value supplied for id".to_string()), + silo_id: Err("no value supplied for silo_id".to_string()), + } + } + } + + impl User { + pub fn display_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.display_name = value.try_into().map_err(|e| { + format!("error converting supplied value for display_name: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn silo_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.silo_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for silo_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::User { + type Error = super::error::ConversionError; + fn try_from(value: User) -> ::std::result::Result { + Ok(Self { + display_name: value.display_name?, + id: value.id?, + silo_id: value.silo_id?, + }) + } + } + + impl ::std::convert::From for User { + fn from(value: super::User) -> Self { + Self { + display_name: Ok(value.display_name), + id: Ok(value.id), + silo_id: Ok(value.silo_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserBuiltin { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserBuiltin { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl UserBuiltin { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::UserBuiltin { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltin, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for UserBuiltin { + fn from(value: super::UserBuiltin) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserBuiltinResultsPage { + items: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserBuiltinResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UserBuiltinResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserBuiltinResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltinResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UserBuiltinResultsPage { + fn from(value: super::UserBuiltinResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserCreate { + external_id: ::std::result::Result, + password: ::std::result::Result, + } + + impl ::std::default::Default for UserCreate { + fn default() -> Self { + Self { + external_id: Err("no value supplied for external_id".to_string()), + password: Err("no value supplied for password".to_string()), + } + } + } + + impl UserCreate { + pub fn external_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.external_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for external_id: {}", e)); + self + } + pub fn password(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserCreate { + type Error = super::error::ConversionError; + fn try_from( + value: UserCreate, + ) -> ::std::result::Result { + Ok(Self { + external_id: value.external_id?, + password: value.password?, + }) + } + } + + impl ::std::convert::From for UserCreate { + fn from(value: super::UserCreate) -> Self { + Self { + external_id: Ok(value.external_id), + password: Ok(value.password), + } + } + } + + #[derive(Clone, Debug)] + pub struct UserResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for UserResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl UserResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UserResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: UserResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for UserResultsPage { + fn from(value: super::UserResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct UsernamePasswordCredentials { + password: ::std::result::Result, + username: ::std::result::Result, + } + + impl ::std::default::Default for UsernamePasswordCredentials { + fn default() -> Self { + Self { + password: Err("no value supplied for password".to_string()), + username: Err("no value supplied for username".to_string()), + } + } + } + + impl UsernamePasswordCredentials { + pub fn password(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.password = value + .try_into() + .map_err(|e| format!("error converting supplied value for password: {}", e)); + self + } + pub fn username(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.username = value + .try_into() + .map_err(|e| format!("error converting supplied value for username: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::UsernamePasswordCredentials { + type Error = super::error::ConversionError; + fn try_from( + value: UsernamePasswordCredentials, + ) -> ::std::result::Result { + Ok(Self { + password: value.password?, + username: value.username?, + }) + } + } + + impl ::std::convert::From for UsernamePasswordCredentials { + fn from(value: super::UsernamePasswordCredentials) -> Self { + Self { + password: Ok(value.password), + username: Ok(value.username), + } + } + } + + #[derive(Clone, Debug)] + pub struct VersionRange { + high: ::std::result::Result, + low: ::std::result::Result, + } + + impl ::std::default::Default for VersionRange { + fn default() -> Self { + Self { + high: Err("no value supplied for high".to_string()), + low: Err("no value supplied for low".to_string()), + } + } + } + + impl VersionRange { + pub fn high(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.high = value + .try_into() + .map_err(|e| format!("error converting supplied value for high: {}", e)); + self + } + pub fn low(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.low = value + .try_into() + .map_err(|e| format!("error converting supplied value for low: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VersionRange { + type Error = super::error::ConversionError; + fn try_from( + value: VersionRange, + ) -> ::std::result::Result { + Ok(Self { + high: value.high?, + low: value.low?, + }) + } + } + + impl ::std::convert::From for VersionRange { + fn from(value: super::VersionRange) -> Self { + Self { + high: Ok(value.high), + low: Ok(value.low), + } + } + } + + #[derive(Clone, Debug)] + pub struct Vpc { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + dns_name: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ipv6_prefix: ::std::result::Result, + name: ::std::result::Result, + project_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + system_router_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + } + + impl ::std::default::Default for Vpc { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + dns_name: Err("no value supplied for dns_name".to_string()), + id: Err("no value supplied for id".to_string()), + ipv6_prefix: Err("no value supplied for ipv6_prefix".to_string()), + name: Err("no value supplied for name".to_string()), + project_id: Err("no value supplied for project_id".to_string()), + system_router_id: Err("no value supplied for system_router_id".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + } + } + } + + impl Vpc { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn ipv6_prefix(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv6_prefix = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_prefix: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn project_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.project_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for project_id: {}", e)); + self + } + pub fn system_router_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.system_router_id = value.try_into().map_err(|e| { + format!( + "error converting supplied value for system_router_id: {}", + e + ) + }); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::Vpc { + type Error = super::error::ConversionError; + fn try_from(value: Vpc) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + id: value.id?, + ipv6_prefix: value.ipv6_prefix?, + name: value.name?, + project_id: value.project_id?, + system_router_id: value.system_router_id?, + time_created: value.time_created?, + time_modified: value.time_modified?, + }) + } + } + + impl ::std::convert::From for Vpc { + fn from(value: super::Vpc) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + id: Ok(value.id), + ipv6_prefix: Ok(value.ipv6_prefix), + name: Ok(value.name), + project_id: Ok(value.project_id), + system_router_id: Ok(value.system_router_id), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + dns_name: ::std::result::Result, + ipv6_prefix: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + dns_name: Err("no value supplied for dns_name".to_string()), + ipv6_prefix: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn ipv6_prefix(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.ipv6_prefix = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_prefix: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + ipv6_prefix: value.ipv6_prefix?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcCreate { + fn from(value: super::VpcCreate) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + ipv6_prefix: Ok(value.ipv6_prefix), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRule { + action: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + direction: + ::std::result::Result, + filters: ::std::result::Result, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + name: ::std::result::Result, + priority: ::std::result::Result, + status: ::std::result::Result, + targets: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcFirewallRule { + fn default() -> Self { + Self { + action: Err("no value supplied for action".to_string()), + description: Err("no value supplied for description".to_string()), + direction: Err("no value supplied for direction".to_string()), + filters: Err("no value supplied for filters".to_string()), + id: Err("no value supplied for id".to_string()), + name: Err("no value supplied for name".to_string()), + priority: Err("no value supplied for priority".to_string()), + status: Err("no value supplied for status".to_string()), + targets: Err("no value supplied for targets".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcFirewallRule { + pub fn action(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.action = value + .try_into() + .map_err(|e| format!("error converting supplied value for action: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn direction(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.direction = value + .try_into() + .map_err(|e| format!("error converting supplied value for direction: {}", e)); + self + } + pub fn filters(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.filters = value + .try_into() + .map_err(|e| format!("error converting supplied value for filters: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn priority(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.priority = value + .try_into() + .map_err(|e| format!("error converting supplied value for priority: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn targets(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.targets = value + .try_into() + .map_err(|e| format!("error converting supplied value for targets: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRule { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRule, + ) -> ::std::result::Result { + Ok(Self { + action: value.action?, + description: value.description?, + direction: value.direction?, + filters: value.filters?, + id: value.id?, + name: value.name?, + priority: value.priority?, + status: value.status?, + targets: value.targets?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRule { + fn from(value: super::VpcFirewallRule) -> Self { + Self { + action: Ok(value.action), + description: Ok(value.description), + direction: Ok(value.direction), + filters: Ok(value.filters), + id: Ok(value.id), + name: Ok(value.name), + priority: Ok(value.priority), + status: Ok(value.status), + targets: Ok(value.targets), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleFilter { + hosts: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + ports: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + protocols: ::std::result::Result< + ::std::option::Option<::std::vec::Vec>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleFilter { + fn default() -> Self { + Self { + hosts: Ok(Default::default()), + ports: Ok(Default::default()), + protocols: Ok(Default::default()), + } + } + } + + impl VpcFirewallRuleFilter { + pub fn hosts(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.hosts = value + .try_into() + .map_err(|e| format!("error converting supplied value for hosts: {}", e)); + self + } + pub fn ports(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.ports = value + .try_into() + .map_err(|e| format!("error converting supplied value for ports: {}", e)); + self + } + pub fn protocols(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option<::std::vec::Vec>, + >, + T::Error: ::std::fmt::Display, + { + self.protocols = value + .try_into() + .map_err(|e| format!("error converting supplied value for protocols: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleFilter { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleFilter, + ) -> ::std::result::Result { + Ok(Self { + hosts: value.hosts?, + ports: value.ports?, + protocols: value.protocols?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleFilter { + fn from(value: super::VpcFirewallRuleFilter) -> Self { + Self { + hosts: Ok(value.hosts), + ports: Ok(value.ports), + protocols: Ok(value.protocols), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleUpdate { + action: ::std::result::Result, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + direction: + ::std::result::Result, + filters: ::std::result::Result, + name: ::std::result::Result, + priority: ::std::result::Result, + status: ::std::result::Result, + targets: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleUpdate { + fn default() -> Self { + Self { + action: Err("no value supplied for action".to_string()), + description: Err("no value supplied for description".to_string()), + direction: Err("no value supplied for direction".to_string()), + filters: Err("no value supplied for filters".to_string()), + name: Err("no value supplied for name".to_string()), + priority: Err("no value supplied for priority".to_string()), + status: Err("no value supplied for status".to_string()), + targets: Err("no value supplied for targets".to_string()), + } + } + } + + impl VpcFirewallRuleUpdate { + pub fn action(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.action = value + .try_into() + .map_err(|e| format!("error converting supplied value for action: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn direction(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.direction = value + .try_into() + .map_err(|e| format!("error converting supplied value for direction: {}", e)); + self + } + pub fn filters(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.filters = value + .try_into() + .map_err(|e| format!("error converting supplied value for filters: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn priority(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.priority = value + .try_into() + .map_err(|e| format!("error converting supplied value for priority: {}", e)); + self + } + pub fn status(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.status = value + .try_into() + .map_err(|e| format!("error converting supplied value for status: {}", e)); + self + } + pub fn targets(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.targets = value + .try_into() + .map_err(|e| format!("error converting supplied value for targets: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdate, + ) -> ::std::result::Result { + Ok(Self { + action: value.action?, + description: value.description?, + direction: value.direction?, + filters: value.filters?, + name: value.name?, + priority: value.priority?, + status: value.status?, + targets: value.targets?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleUpdate { + fn from(value: super::VpcFirewallRuleUpdate) -> Self { + Self { + action: Ok(value.action), + description: Ok(value.description), + direction: Ok(value.direction), + filters: Ok(value.filters), + name: Ok(value.name), + priority: Ok(value.priority), + status: Ok(value.status), + targets: Ok(value.targets), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRuleUpdateParams { + rules: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRuleUpdateParams { + fn default() -> Self { + Self { + rules: Err("no value supplied for rules".to_string()), + } + } + } + + impl VpcFirewallRuleUpdateParams { + pub fn rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.rules = value + .try_into() + .map_err(|e| format!("error converting supplied value for rules: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdateParams, + ) -> ::std::result::Result { + Ok(Self { + rules: value.rules?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRuleUpdateParams { + fn from(value: super::VpcFirewallRuleUpdateParams) -> Self { + Self { + rules: Ok(value.rules), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcFirewallRules { + rules: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcFirewallRules { + fn default() -> Self { + Self { + rules: Err("no value supplied for rules".to_string()), + } + } + } + + impl VpcFirewallRules { + pub fn rules(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.rules = value + .try_into() + .map_err(|e| format!("error converting supplied value for rules: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcFirewallRules { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRules, + ) -> ::std::result::Result { + Ok(Self { + rules: value.rules?, + }) + } + } + + impl ::std::convert::From for VpcFirewallRules { + fn from(value: super::VpcFirewallRules) -> Self { + Self { + rules: Ok(value.rules), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcResultsPage { + fn from(value: super::VpcResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouter { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + kind: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcRouter { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + kind: Err("no value supplied for kind".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcRouter { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn kind(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.kind = value + .try_into() + .map_err(|e| format!("error converting supplied value for kind: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouter { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouter, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + kind: value.kind?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcRouter { + fn from(value: super::VpcRouter) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + kind: Ok(value.kind), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcRouterCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcRouterCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcRouterCreate { + fn from(value: super::VpcRouterCreate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcRouterResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcRouterResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcRouterResultsPage { + fn from(value: super::VpcRouterResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcRouterUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcRouterUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcRouterUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcRouterUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcRouterUpdate { + fn from(value: super::VpcRouterUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnet { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + ipv4_block: ::std::result::Result, + ipv6_block: ::std::result::Result, + name: ::std::result::Result, + time_created: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + time_modified: ::std::result::Result< + ::chrono::DateTime<::chrono::offset::Utc>, + ::std::string::String, + >, + vpc_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for VpcSubnet { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + ipv4_block: Err("no value supplied for ipv4_block".to_string()), + ipv6_block: Err("no value supplied for ipv6_block".to_string()), + name: Err("no value supplied for name".to_string()), + time_created: Err("no value supplied for time_created".to_string()), + time_modified: Err("no value supplied for time_modified".to_string()), + vpc_id: Err("no value supplied for vpc_id".to_string()), + } + } + } + + impl VpcSubnet { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn ipv4_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv4_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv4_block: {}", e)); + self + } + pub fn ipv6_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv6_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_block: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn time_created(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_created = value.try_into().map_err(|e| { + format!("error converting supplied value for time_created: {}", e) + }); + self + } + pub fn time_modified(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + T::Error: ::std::fmt::Display, + { + self.time_modified = value.try_into().map_err(|e| { + format!("error converting supplied value for time_modified: {}", e) + }); + self + } + pub fn vpc_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.vpc_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for vpc_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnet { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnet, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + id: value.id?, + ipv4_block: value.ipv4_block?, + ipv6_block: value.ipv6_block?, + name: value.name?, + time_created: value.time_created?, + time_modified: value.time_modified?, + vpc_id: value.vpc_id?, + }) + } + } + + impl ::std::convert::From for VpcSubnet { + fn from(value: super::VpcSubnet) -> Self { + Self { + description: Ok(value.description), + id: Ok(value.id), + ipv4_block: Ok(value.ipv4_block), + ipv6_block: Ok(value.ipv6_block), + name: Ok(value.name), + time_created: Ok(value.time_created), + time_modified: Ok(value.time_modified), + vpc_id: Ok(value.vpc_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetCreate { + description: ::std::result::Result<::std::string::String, ::std::string::String>, + ipv4_block: ::std::result::Result, + ipv6_block: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result, + } + + impl ::std::default::Default for VpcSubnetCreate { + fn default() -> Self { + Self { + description: Err("no value supplied for description".to_string()), + ipv4_block: Err("no value supplied for ipv4_block".to_string()), + ipv6_block: Ok(Default::default()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl VpcSubnetCreate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn ipv4_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.ipv4_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv4_block: {}", e)); + self + } + pub fn ipv6_block(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.ipv6_block = value + .try_into() + .map_err(|e| format!("error converting supplied value for ipv6_block: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetCreate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetCreate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + ipv4_block: value.ipv4_block?, + ipv6_block: value.ipv6_block?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcSubnetCreate { + fn from(value: super::VpcSubnetCreate) -> Self { + Self { + description: Ok(value.description), + ipv4_block: Ok(value.ipv4_block), + ipv6_block: Ok(value.ipv6_block), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetResultsPage { + items: ::std::result::Result<::std::vec::Vec, ::std::string::String>, + next_page: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for VpcSubnetResultsPage { + fn default() -> Self { + Self { + items: Err("no value supplied for items".to_string()), + next_page: Ok(Default::default()), + } + } + } + + impl VpcSubnetResultsPage { + pub fn items(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.items = value + .try_into() + .map_err(|e| format!("error converting supplied value for items: {}", e)); + self + } + pub fn next_page(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.next_page = value + .try_into() + .map_err(|e| format!("error converting supplied value for next_page: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetResultsPage { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetResultsPage, + ) -> ::std::result::Result { + Ok(Self { + items: value.items?, + next_page: value.next_page?, + }) + } + } + + impl ::std::convert::From for VpcSubnetResultsPage { + fn from(value: super::VpcSubnetResultsPage) -> Self { + Self { + items: Ok(value.items), + next_page: Ok(value.next_page), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcSubnetUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcSubnetUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcSubnetUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcSubnetUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcSubnetUpdate { + fn from(value: super::VpcSubnetUpdate) -> Self { + Self { + description: Ok(value.description), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct VpcUpdate { + description: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + dns_name: + ::std::result::Result<::std::option::Option, ::std::string::String>, + name: ::std::result::Result<::std::option::Option, ::std::string::String>, + } + + impl ::std::default::Default for VpcUpdate { + fn default() -> Self { + Self { + description: Ok(Default::default()), + dns_name: Ok(Default::default()), + name: Ok(Default::default()), + } + } + } + + impl VpcUpdate { + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn dns_name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.dns_name = value + .try_into() + .map_err(|e| format!("error converting supplied value for dns_name: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::VpcUpdate { + type Error = super::error::ConversionError; + fn try_from( + value: VpcUpdate, + ) -> ::std::result::Result { + Ok(Self { + description: value.description?, + dns_name: value.dns_name?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for VpcUpdate { + fn from(value: super::VpcUpdate) -> Self { + Self { + description: Ok(value.description), + dns_name: Ok(value.dns_name), + name: Ok(value.name), + } + } + } + } + + /// Generation of default values for serde. + pub mod defaults { + pub(super) fn default_bool() -> bool { + V + } + + pub(super) fn instance_create_network_interfaces( + ) -> super::InstanceNetworkInterfaceAttachment { + super::InstanceNetworkInterfaceAttachment::Default + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +///Virtual disks are used to store instance-local data which includes the +/// operating system. +pub trait ClientDisksExt { + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to `/by-id/disks/{id}` + /// + ///```ignore + /// let response = client.disk_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn disk_view_by_id(&self) -> builder::DiskViewById<'_>; + ///List disks + /// + ///Use `GET /v1/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.disk_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn disk_list(&self) -> builder::DiskList<'_>; + ///Use `POST /v1/disks` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.disk_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn disk_create(&self) -> builder::DiskCreate<'_>; + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + /// + ///```ignore + /// let response = client.disk_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + fn disk_view(&self) -> builder::DiskView<'_>; + ///Use `DELETE /v1/disks/{disk}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + /// + ///```ignore + /// let response = client.disk_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + fn disk_delete(&self) -> builder::DiskDelete<'_>; + ///Fetch disk metrics + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `disk_name` + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.disk_metrics_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + fn disk_metrics_list(&self) -> builder::DiskMetricsList<'_>; + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.disk_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn disk_list_v1(&self) -> builder::DiskListV1<'_>; + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + /// + ///```ignore + /// let response = client.disk_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn disk_create_v1(&self) -> builder::DiskCreateV1<'_>; + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_view_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn disk_view_v1(&self) -> builder::DiskViewV1<'_>; + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + /// + ///```ignore + /// let response = client.disk_delete_v1() + /// .disk(disk) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn disk_delete_v1(&self) -> builder::DiskDeleteV1<'_>; +} + +impl ClientDisksExt for Client { + fn disk_view_by_id(&self) -> builder::DiskViewById<'_> { + builder::DiskViewById::new(self) + } + + fn disk_list(&self) -> builder::DiskList<'_> { + builder::DiskList::new(self) + } + + fn disk_create(&self) -> builder::DiskCreate<'_> { + builder::DiskCreate::new(self) + } + + fn disk_view(&self) -> builder::DiskView<'_> { + builder::DiskView::new(self) + } + + fn disk_delete(&self) -> builder::DiskDelete<'_> { + builder::DiskDelete::new(self) + } + + fn disk_metrics_list(&self) -> builder::DiskMetricsList<'_> { + builder::DiskMetricsList::new(self) + } + + fn disk_list_v1(&self) -> builder::DiskListV1<'_> { + builder::DiskListV1::new(self) + } + + fn disk_create_v1(&self) -> builder::DiskCreateV1<'_> { + builder::DiskCreateV1::new(self) + } + + fn disk_view_v1(&self) -> builder::DiskViewV1<'_> { + builder::DiskViewV1::new(self) + } + + fn disk_delete_v1(&self) -> builder::DiskDeleteV1<'_> { + builder::DiskDeleteV1::new(self) + } +} + +///TODO operations that will not ship to customers +pub trait ClientHiddenExt { + ///Start an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed from an *unauthenticated* API + /// client. It generates and records a `device_code` and `user_code` which + /// must be verified and confirmed prior to a token being granted. + /// + ///Sends a `POST` request to `/device/auth` + /// + ///```ignore + /// let response = client.device_auth_request() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn device_auth_request(&self) -> builder::DeviceAuthRequest<'_>; + ///Confirm an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed by the user agent (browser), + /// not the client requesting the token. So we do not actually return the + /// token here; it will be returned in response to the poll on + /// `/device/token`. + /// + ///Sends a `POST` request to `/device/confirm` + /// + ///```ignore + /// let response = client.device_auth_confirm() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn device_auth_confirm(&self) -> builder::DeviceAuthConfirm<'_>; + ///Request a device access token + /// + ///This endpoint should be polled by the client until the user code is + /// verified and the grant is confirmed. + /// + ///Sends a `POST` request to `/device/token` + /// + ///```ignore + /// let response = client.device_access_token() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn device_access_token(&self) -> builder::DeviceAccessToken<'_>; + ///Sends a `POST` request to `/login` + /// + ///```ignore + /// let response = client.login_spoof() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn login_spoof(&self) -> builder::LoginSpoof<'_>; + ///Sends a `POST` request to `/logout` + /// + ///```ignore + /// let response = client.logout() + /// .send() + /// .await; + /// ``` + fn logout(&self) -> builder::Logout<'_>; + ///Fetch the user associated with the current session + /// + ///Sends a `GET` request to `/session/me` + /// + ///```ignore + /// let response = client.session_me() + /// .send() + /// .await; + /// ``` + fn session_me(&self) -> builder::SessionMe<'_>; + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_me_groups() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn session_me_groups(&self) -> builder::SessionMeGroups<'_>; +} + +impl ClientHiddenExt for Client { + fn device_auth_request(&self) -> builder::DeviceAuthRequest<'_> { + builder::DeviceAuthRequest::new(self) + } + + fn device_auth_confirm(&self) -> builder::DeviceAuthConfirm<'_> { + builder::DeviceAuthConfirm::new(self) + } + + fn device_access_token(&self) -> builder::DeviceAccessToken<'_> { + builder::DeviceAccessToken::new(self) + } + + fn login_spoof(&self) -> builder::LoginSpoof<'_> { + builder::LoginSpoof::new(self) + } + + fn logout(&self) -> builder::Logout<'_> { + builder::Logout::new(self) + } + + fn session_me(&self) -> builder::SessionMe<'_> { + builder::SessionMe::new(self) + } + + fn session_me_groups(&self) -> builder::SessionMeGroups<'_> { + builder::SessionMeGroups::new(self) + } +} + +///Images are read-only Virtual Disks that may be used to boot Virtual Machines +pub trait ClientImagesExt { + ///Fetch an image by id + /// + ///Sends a `GET` request to `/by-id/images/{id}` + /// + ///```ignore + /// let response = client.image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn image_view_by_id(&self) -> builder::ImageViewById<'_>; + ///List images + /// + ///List images in a project. The images are returned sorted by creation + /// date, with the most recent images appearing first. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.image_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn image_list(&self) -> builder::ImageList<'_>; + ///Create an image + /// + ///Create a new image in a project. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.image_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn image_create(&self) -> builder::ImageCreate<'_>; + ///Fetch an image + /// + ///Fetch the details for a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + /// + ///```ignore + /// let response = client.image_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn image_view(&self) -> builder::ImageView<'_>; + ///Delete an image + /// + ///Permanently delete an image from a project. This operation cannot be + /// undone. Any instances in the project using the image will continue to + /// run, however new instances can not be created with this image. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + /// + ///```ignore + /// let response = client.image_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn image_delete(&self) -> builder::ImageDelete<'_>; +} + +impl ClientImagesExt for Client { + fn image_view_by_id(&self) -> builder::ImageViewById<'_> { + builder::ImageViewById::new(self) + } + + fn image_list(&self) -> builder::ImageList<'_> { + builder::ImageList::new(self) + } + + fn image_create(&self) -> builder::ImageCreate<'_> { + builder::ImageCreate::new(self) + } + + fn image_view(&self) -> builder::ImageView<'_> { + builder::ImageView::new(self) + } + + fn image_delete(&self) -> builder::ImageDelete<'_> { + builder::ImageDelete::new(self) + } +} + +///Virtual machine instances are the basic unit of computation. These +/// operations are used for provisioning, controlling, and destroying instances. +pub trait ClientInstancesExt { + ///Fetch an instance by id + /// + ///Sends a `GET` request to `/by-id/instances/{id}` + /// + ///```ignore + /// let response = client.instance_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn instance_view_by_id(&self) -> builder::InstanceViewById<'_>; + ///Fetch a network interface by id + /// + ///Sends a `GET` request to `/by-id/network-interfaces/{id}` + /// + ///```ignore + /// let response = client.instance_network_interface_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_view_by_id( + &self, + ) -> builder::InstanceNetworkInterfaceViewById<'_>; + ///List instances + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_list(&self) -> builder::InstanceList<'_>; + ///Create an instance + /// + ///Use `POST /v1/instances` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.instance_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_create(&self) -> builder::InstanceCreate<'_>; + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + /// + ///```ignore + /// let response = client.instance_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_view(&self) -> builder::InstanceView<'_>; + ///Delete an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + /// + ///```ignore + /// let response = client.instance_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_delete(&self) -> builder::InstanceDelete<'_>; + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_disk_list(&self) -> builder::InstanceDiskList<'_>; + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_attach(&self) -> builder::InstanceDiskAttach<'_>; + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_detach(&self) -> builder::InstanceDiskDetach<'_>; + ///List external IP addresses + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/external-ips` + /// + ///```ignore + /// let response = client.instance_external_ip_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_external_ip_list(&self) -> builder::InstanceExternalIpList<'_>; + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_migrate(&self) -> builder::InstanceMigrate<'_>; + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.instance_network_interface_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_list(&self) -> builder::InstanceNetworkInterfaceList<'_>; + ///Create a network interface + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + /// + ///```ignore + /// let response = client.instance_network_interface_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_create(&self) -> builder::InstanceNetworkInterfaceCreate<'_>; + ///Fetch a network interface + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_view(&self) -> builder::InstanceNetworkInterfaceView<'_>; + ///Update a network interface + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_update(&self) -> builder::InstanceNetworkInterfaceUpdate<'_>; + ///Delete a network interface + /// + ///Note that the primary interface for an instance cannot be deleted if + /// there are any secondary interfaces. A new primary interface must be + /// designated first. The primary interface can be deleted if there are no + /// secondary interfaces. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + /// + ///```ignore + /// let response = client.instance_network_interface_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + fn instance_network_interface_delete(&self) -> builder::InstanceNetworkInterfaceDelete<'_>; + ///Reboot an instance + /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_reboot(&self) -> builder::InstanceReboot<'_>; + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + ///```ignore + /// let response = client.instance_serial_console() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .send() + /// .await; + /// ``` + fn instance_serial_console(&self) -> builder::InstanceSerialConsole<'_>; + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream<'_>; + ///Boot an instance + /// + ///Use `POST /v1/instances/{instance}/start` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` + /// + ///```ignore + /// let response = client.instance_start() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_start(&self) -> builder::InstanceStart<'_>; + ///Halt an instance + /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` + /// + ///```ignore + /// let response = client.instance_stop() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn instance_stop(&self) -> builder::InstanceStop<'_>; + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_list_v1(&self) -> builder::InstanceListV1<'_>; + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + /// + ///```ignore + /// let response = client.instance_create_v1() + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_create_v1(&self) -> builder::InstanceCreateV1<'_>; + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_view_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_view_v1(&self) -> builder::InstanceViewV1<'_>; + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + /// + ///```ignore + /// let response = client.instance_delete_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_delete_v1(&self) -> builder::InstanceDeleteV1<'_>; + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + ///```ignore + /// let response = client.instance_disk_list_v1() + /// .instance(instance) + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .project(project) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1<'_>; + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + /// + ///```ignore + /// let response = client.instance_disk_attach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1<'_>; + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + /// + ///```ignore + /// let response = client.instance_disk_detach_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1<'_>; + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + /// + ///```ignore + /// let response = client.instance_migrate_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1<'_>; + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + /// + ///```ignore + /// let response = client.instance_reboot_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_reboot_v1(&self) -> builder::InstanceRebootV1<'_>; + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + ///```ignore + /// let response = client.instance_serial_console_v1() + /// .instance(instance) + /// .from_start(from_start) + /// .max_bytes(max_bytes) + /// .most_recent(most_recent) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1<'_>; + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + /// + ///```ignore + /// let response = client.instance_serial_console_stream_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1<'_>; + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + /// + ///```ignore + /// let response = client.instance_start_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_start_v1(&self) -> builder::InstanceStartV1<'_>; + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + /// + ///```ignore + /// let response = client.instance_stop_v1() + /// .instance(instance) + /// .organization(organization) + /// .project(project) + /// .send() + /// .await; + /// ``` + fn instance_stop_v1(&self) -> builder::InstanceStopV1<'_>; +} + +impl ClientInstancesExt for Client { + fn instance_view_by_id(&self) -> builder::InstanceViewById<'_> { + builder::InstanceViewById::new(self) + } + + fn instance_network_interface_view_by_id( + &self, + ) -> builder::InstanceNetworkInterfaceViewById<'_> { + builder::InstanceNetworkInterfaceViewById::new(self) + } + + fn instance_list(&self) -> builder::InstanceList<'_> { + builder::InstanceList::new(self) + } + + fn instance_create(&self) -> builder::InstanceCreate<'_> { + builder::InstanceCreate::new(self) + } + + fn instance_view(&self) -> builder::InstanceView<'_> { + builder::InstanceView::new(self) + } + + fn instance_delete(&self) -> builder::InstanceDelete<'_> { + builder::InstanceDelete::new(self) + } + + fn instance_disk_list(&self) -> builder::InstanceDiskList<'_> { + builder::InstanceDiskList::new(self) + } + + fn instance_disk_attach(&self) -> builder::InstanceDiskAttach<'_> { + builder::InstanceDiskAttach::new(self) + } + + fn instance_disk_detach(&self) -> builder::InstanceDiskDetach<'_> { + builder::InstanceDiskDetach::new(self) + } + + fn instance_external_ip_list(&self) -> builder::InstanceExternalIpList<'_> { + builder::InstanceExternalIpList::new(self) + } + + fn instance_migrate(&self) -> builder::InstanceMigrate<'_> { + builder::InstanceMigrate::new(self) + } + + fn instance_network_interface_list(&self) -> builder::InstanceNetworkInterfaceList<'_> { + builder::InstanceNetworkInterfaceList::new(self) + } + + fn instance_network_interface_create(&self) -> builder::InstanceNetworkInterfaceCreate<'_> { + builder::InstanceNetworkInterfaceCreate::new(self) + } + + fn instance_network_interface_view(&self) -> builder::InstanceNetworkInterfaceView<'_> { + builder::InstanceNetworkInterfaceView::new(self) + } + + fn instance_network_interface_update(&self) -> builder::InstanceNetworkInterfaceUpdate<'_> { + builder::InstanceNetworkInterfaceUpdate::new(self) + } + + fn instance_network_interface_delete(&self) -> builder::InstanceNetworkInterfaceDelete<'_> { + builder::InstanceNetworkInterfaceDelete::new(self) + } + + fn instance_reboot(&self) -> builder::InstanceReboot<'_> { + builder::InstanceReboot::new(self) + } + + fn instance_serial_console(&self) -> builder::InstanceSerialConsole<'_> { + builder::InstanceSerialConsole::new(self) + } + + fn instance_serial_console_stream(&self) -> builder::InstanceSerialConsoleStream<'_> { + builder::InstanceSerialConsoleStream::new(self) + } + + fn instance_start(&self) -> builder::InstanceStart<'_> { + builder::InstanceStart::new(self) + } + + fn instance_stop(&self) -> builder::InstanceStop<'_> { + builder::InstanceStop::new(self) + } + + fn instance_list_v1(&self) -> builder::InstanceListV1<'_> { + builder::InstanceListV1::new(self) + } + + fn instance_create_v1(&self) -> builder::InstanceCreateV1<'_> { + builder::InstanceCreateV1::new(self) + } + + fn instance_view_v1(&self) -> builder::InstanceViewV1<'_> { + builder::InstanceViewV1::new(self) + } + + fn instance_delete_v1(&self) -> builder::InstanceDeleteV1<'_> { + builder::InstanceDeleteV1::new(self) + } + + fn instance_disk_list_v1(&self) -> builder::InstanceDiskListV1<'_> { + builder::InstanceDiskListV1::new(self) + } + + fn instance_disk_attach_v1(&self) -> builder::InstanceDiskAttachV1<'_> { + builder::InstanceDiskAttachV1::new(self) + } + + fn instance_disk_detach_v1(&self) -> builder::InstanceDiskDetachV1<'_> { + builder::InstanceDiskDetachV1::new(self) + } + + fn instance_migrate_v1(&self) -> builder::InstanceMigrateV1<'_> { + builder::InstanceMigrateV1::new(self) + } + + fn instance_reboot_v1(&self) -> builder::InstanceRebootV1<'_> { + builder::InstanceRebootV1::new(self) + } + + fn instance_serial_console_v1(&self) -> builder::InstanceSerialConsoleV1<'_> { + builder::InstanceSerialConsoleV1::new(self) + } + + fn instance_serial_console_stream_v1(&self) -> builder::InstanceSerialConsoleStreamV1<'_> { + builder::InstanceSerialConsoleStreamV1::new(self) + } + + fn instance_start_v1(&self) -> builder::InstanceStartV1<'_> { + builder::InstanceStartV1::new(self) + } + + fn instance_stop_v1(&self) -> builder::InstanceStopV1<'_> { + builder::InstanceStopV1::new(self) + } +} + +///Authentication endpoints +pub trait ClientLoginExt { + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + /// + ///```ignore + /// let response = client.login_local() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn login_local(&self) -> builder::LoginLocal<'_>; + ///Prompt user login + /// + ///Either display a page asking a user for their credentials, or redirect + /// them to their identity provider. + /// + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + /// + ///```ignore + /// let response = client.login_saml_begin() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + fn login_saml_begin(&self) -> builder::LoginSamlBegin<'_>; + ///Authenticate a user (i.e., log in) via SAML + /// + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + /// + ///```ignore + /// let response = client.login_saml() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn login_saml(&self) -> builder::LoginSaml<'_>; +} + +impl ClientLoginExt for Client { + fn login_local(&self) -> builder::LoginLocal<'_> { + builder::LoginLocal::new(self) + } + + fn login_saml_begin(&self) -> builder::LoginSamlBegin<'_> { + builder::LoginSamlBegin::new(self) + } + + fn login_saml(&self) -> builder::LoginSaml<'_> { + builder::LoginSaml::new(self) + } +} + +///Metrics provide insight into the operation of the Oxide deployment. These +/// include telemetry on hardware and software components that can be used to +/// understand the current state as well as to diagnose issues. +pub trait ClientMetricsExt { + ///List timeseries schema + /// + ///Sends a `GET` request to `/timeseries/schema` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.timeseries_schema_get() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn timeseries_schema_get(&self) -> builder::TimeseriesSchemaGet<'_>; +} + +impl ClientMetricsExt for Client { + fn timeseries_schema_get(&self) -> builder::TimeseriesSchemaGet<'_> { + builder::TimeseriesSchemaGet::new(self) + } +} + +///Organizations represent a subset of users and projects in an Oxide +/// deployment. +pub trait ClientOrganizationsExt { + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/by-id/organizations/{id}` + /// + ///```ignore + /// let response = client.organization_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn organization_view_by_id(&self) -> builder::OrganizationViewById<'_>; + ///List organizations + /// + ///Use `GET /v1/organizations` instead + /// + ///Sends a `GET` request to `/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn organization_list(&self) -> builder::OrganizationList<'_>; + ///Create an organization + /// + ///Use `POST /v1/organizations` instead + /// + ///Sends a `POST` request to `/organizations` + /// + ///```ignore + /// let response = client.organization_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_create(&self) -> builder::OrganizationCreate<'_>; + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_view() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organization_view(&self) -> builder::OrganizationView<'_>; + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.organization_update() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_update(&self) -> builder::OrganizationUpdate<'_>; + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_delete() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organization_delete(&self) -> builder::OrganizationDelete<'_>; + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + ///```ignore + /// let response = client.organization_policy_view() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organization_policy_view(&self) -> builder::OrganizationPolicyView<'_>; + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.organization_policy_update() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_policy_update(&self) -> builder::OrganizationPolicyUpdate<'_>; + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.organization_list_v1() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn organization_list_v1(&self) -> builder::OrganizationListV1<'_>; + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + /// + ///```ignore + /// let response = client.organization_create_v1() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_create_v1(&self) -> builder::OrganizationCreateV1<'_>; + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_view_v1(&self) -> builder::OrganizationViewV1<'_>; + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_update_v1(&self) -> builder::OrganizationUpdateV1<'_>; + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + /// + ///```ignore + /// let response = client.organization_delete_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1<'_>; + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_view_v1() + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1<'_>; + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + /// + ///```ignore + /// let response = client.organization_policy_update_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1<'_>; +} + +impl ClientOrganizationsExt for Client { + fn organization_view_by_id(&self) -> builder::OrganizationViewById<'_> { + builder::OrganizationViewById::new(self) + } + + fn organization_list(&self) -> builder::OrganizationList<'_> { + builder::OrganizationList::new(self) + } + + fn organization_create(&self) -> builder::OrganizationCreate<'_> { + builder::OrganizationCreate::new(self) + } + + fn organization_view(&self) -> builder::OrganizationView<'_> { + builder::OrganizationView::new(self) + } + + fn organization_update(&self) -> builder::OrganizationUpdate<'_> { + builder::OrganizationUpdate::new(self) + } + + fn organization_delete(&self) -> builder::OrganizationDelete<'_> { + builder::OrganizationDelete::new(self) + } + + fn organization_policy_view(&self) -> builder::OrganizationPolicyView<'_> { + builder::OrganizationPolicyView::new(self) + } + + fn organization_policy_update(&self) -> builder::OrganizationPolicyUpdate<'_> { + builder::OrganizationPolicyUpdate::new(self) + } + + fn organization_list_v1(&self) -> builder::OrganizationListV1<'_> { + builder::OrganizationListV1::new(self) + } + + fn organization_create_v1(&self) -> builder::OrganizationCreateV1<'_> { + builder::OrganizationCreateV1::new(self) + } + + fn organization_view_v1(&self) -> builder::OrganizationViewV1<'_> { + builder::OrganizationViewV1::new(self) + } + + fn organization_update_v1(&self) -> builder::OrganizationUpdateV1<'_> { + builder::OrganizationUpdateV1::new(self) + } + + fn organization_delete_v1(&self) -> builder::OrganizationDeleteV1<'_> { + builder::OrganizationDeleteV1::new(self) + } + + fn organization_policy_view_v1(&self) -> builder::OrganizationPolicyViewV1<'_> { + builder::OrganizationPolicyViewV1::new(self) + } + + fn organization_policy_update_v1(&self) -> builder::OrganizationPolicyUpdateV1<'_> { + builder::OrganizationPolicyUpdateV1::new(self) + } +} + +///System-wide IAM policy +pub trait ClientPolicyExt { + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_view() + /// .send() + /// .await; + /// ``` + fn system_policy_view(&self) -> builder::SystemPolicyView<'_>; + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/system/policy` + /// + ///```ignore + /// let response = client.system_policy_update() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_policy_update(&self) -> builder::SystemPolicyUpdate<'_>; +} + +impl ClientPolicyExt for Client { + fn system_policy_view(&self) -> builder::SystemPolicyView<'_> { + builder::SystemPolicyView::new(self) + } + + fn system_policy_update(&self) -> builder::SystemPolicyUpdate<'_> { + builder::SystemPolicyUpdate::new(self) + } +} + +///Projects are a grouping of associated resources such as instances and disks +/// within an organization for purposes of billing and access control. +pub trait ClientProjectsExt { + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to `/by-id/projects/{id}` + /// + ///```ignore + /// let response = client.project_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn project_view_by_id(&self) -> builder::ProjectViewById<'_>; + ///List projects + /// + ///Use `GET /v1/projects` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list() + /// .organization_name(organization_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_list(&self) -> builder::ProjectList<'_>; + ///Create a project + /// + ///Use `POST /v1/projects` instead + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + ///```ignore + /// let response = client.project_create() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_create(&self) -> builder::ProjectCreate<'_>; + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn project_view(&self) -> builder::ProjectView<'_>; + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.project_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_update(&self) -> builder::ProjectUpdate<'_>; + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn project_delete(&self) -> builder::ProjectDelete<'_>; + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + ///```ignore + /// let response = client.project_policy_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn project_policy_view(&self) -> builder::ProjectPolicyView<'_>; + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.project_policy_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_policy_update(&self) -> builder::ProjectPolicyUpdate<'_>; + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.project_list_v1() + /// .limit(limit) + /// .organization(organization) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_list_v1(&self) -> builder::ProjectListV1<'_>; + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + /// + ///```ignore + /// let response = client.project_create_v1() + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_create_v1(&self) -> builder::ProjectCreateV1<'_>; + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_view_v1(&self) -> builder::ProjectViewV1<'_>; + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_update_v1(&self) -> builder::ProjectUpdateV1<'_>; + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + /// + ///```ignore + /// let response = client.project_delete_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_delete_v1(&self) -> builder::ProjectDeleteV1<'_>; + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_view_v1() + /// .project(project) + /// .organization(organization) + /// .send() + /// .await; + /// ``` + fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1<'_>; + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + /// + ///```ignore + /// let response = client.project_policy_update_v1() + /// .project(project) + /// .organization(organization) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1<'_>; +} + +impl ClientProjectsExt for Client { + fn project_view_by_id(&self) -> builder::ProjectViewById<'_> { + builder::ProjectViewById::new(self) + } + + fn project_list(&self) -> builder::ProjectList<'_> { + builder::ProjectList::new(self) + } + + fn project_create(&self) -> builder::ProjectCreate<'_> { + builder::ProjectCreate::new(self) + } + + fn project_view(&self) -> builder::ProjectView<'_> { + builder::ProjectView::new(self) + } + + fn project_update(&self) -> builder::ProjectUpdate<'_> { + builder::ProjectUpdate::new(self) + } + + fn project_delete(&self) -> builder::ProjectDelete<'_> { + builder::ProjectDelete::new(self) + } + + fn project_policy_view(&self) -> builder::ProjectPolicyView<'_> { + builder::ProjectPolicyView::new(self) + } + + fn project_policy_update(&self) -> builder::ProjectPolicyUpdate<'_> { + builder::ProjectPolicyUpdate::new(self) + } + + fn project_list_v1(&self) -> builder::ProjectListV1<'_> { + builder::ProjectListV1::new(self) + } + + fn project_create_v1(&self) -> builder::ProjectCreateV1<'_> { + builder::ProjectCreateV1::new(self) + } + + fn project_view_v1(&self) -> builder::ProjectViewV1<'_> { + builder::ProjectViewV1::new(self) + } + + fn project_update_v1(&self) -> builder::ProjectUpdateV1<'_> { + builder::ProjectUpdateV1::new(self) + } + + fn project_delete_v1(&self) -> builder::ProjectDeleteV1<'_> { + builder::ProjectDeleteV1::new(self) + } + + fn project_policy_view_v1(&self) -> builder::ProjectPolicyViewV1<'_> { + builder::ProjectPolicyViewV1::new(self) + } + + fn project_policy_update_v1(&self) -> builder::ProjectPolicyUpdateV1<'_> { + builder::ProjectPolicyUpdateV1::new(self) + } +} + +///Roles are a component of Identity and Access Management (IAM) that allow a +/// user or agent account access to additional permissions. +pub trait ClientRolesExt { + ///List built-in roles + /// + ///Sends a `GET` request to `/roles` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.role_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn role_list(&self) -> builder::RoleList<'_>; + ///Fetch a built-in role + /// + ///Sends a `GET` request to `/roles/{role_name}` + /// + ///Arguments: + /// - `role_name`: The built-in role's unique name. + ///```ignore + /// let response = client.role_view() + /// .role_name(role_name) + /// .send() + /// .await; + /// ``` + fn role_view(&self) -> builder::RoleView<'_>; +} + +impl ClientRolesExt for Client { + fn role_list(&self) -> builder::RoleList<'_> { + builder::RoleList::new(self) + } + + fn role_view(&self) -> builder::RoleView<'_> { + builder::RoleView::new(self) + } +} + +///Information pertaining to the current session. +pub trait ClientSessionExt { + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. + /// + ///Sends a `GET` request to `/session/me/sshkeys` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.session_sshkey_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn session_sshkey_list(&self) -> builder::SessionSshkeyList<'_>; + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. + /// + ///Sends a `POST` request to `/session/me/sshkeys` + /// + ///```ignore + /// let response = client.session_sshkey_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn session_sshkey_create(&self) -> builder::SessionSshkeyCreate<'_>; + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + /// + ///```ignore + /// let response = client.session_sshkey_view() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + fn session_sshkey_view(&self) -> builder::SessionSshkeyView<'_>; + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + /// + ///```ignore + /// let response = client.session_sshkey_delete() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + fn session_sshkey_delete(&self) -> builder::SessionSshkeyDelete<'_>; +} + +impl ClientSessionExt for Client { + fn session_sshkey_list(&self) -> builder::SessionSshkeyList<'_> { + builder::SessionSshkeyList::new(self) + } + + fn session_sshkey_create(&self) -> builder::SessionSshkeyCreate<'_> { + builder::SessionSshkeyCreate::new(self) + } + + fn session_sshkey_view(&self) -> builder::SessionSshkeyView<'_> { + builder::SessionSshkeyView::new(self) + } + + fn session_sshkey_delete(&self) -> builder::SessionSshkeyDelete<'_> { + builder::SessionSshkeyDelete::new(self) + } +} + +///Silos represent a logical partition of users and resources. +pub trait ClientSilosExt { + ///List groups + /// + ///Sends a `GET` request to `/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.group_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn group_list(&self) -> builder::GroupList<'_>; + ///Fetch the current silo's IAM policy + /// + ///Sends a `GET` request to `/policy` + /// + ///```ignore + /// let response = client.policy_view() + /// .send() + /// .await; + /// ``` + fn policy_view(&self) -> builder::PolicyView<'_>; + ///Update the current silo's IAM policy + /// + ///Sends a `PUT` request to `/policy` + /// + ///```ignore + /// let response = client.policy_update() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn policy_update(&self) -> builder::PolicyUpdate<'_>; + ///List users + /// + ///Sends a `GET` request to `/users` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.user_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn user_list(&self) -> builder::UserList<'_>; +} + +impl ClientSilosExt for Client { + fn group_list(&self) -> builder::GroupList<'_> { + builder::GroupList::new(self) + } + + fn policy_view(&self) -> builder::PolicyView<'_> { + builder::PolicyView::new(self) + } + + fn policy_update(&self) -> builder::PolicyUpdate<'_> { + builder::PolicyUpdate::new(self) + } + + fn user_list(&self) -> builder::UserList<'_> { + builder::UserList::new(self) + } +} + +///Snapshots of Virtual Disks at a particular point in time. +pub trait ClientSnapshotsExt { + ///Fetch a snapshot by id + /// + ///Sends a `GET` request to `/by-id/snapshots/{id}` + /// + ///```ignore + /// let response = client.snapshot_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn snapshot_view_by_id(&self) -> builder::SnapshotViewById<'_>; + ///List snapshots + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.snapshot_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn snapshot_list(&self) -> builder::SnapshotList<'_>; + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.snapshot_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn snapshot_create(&self) -> builder::SnapshotCreate<'_>; + ///Fetch a snapshot + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + /// + ///```ignore + /// let response = client.snapshot_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + fn snapshot_view(&self) -> builder::SnapshotView<'_>; + ///Delete a snapshot + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + /// + ///```ignore + /// let response = client.snapshot_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + fn snapshot_delete(&self) -> builder::SnapshotDelete<'_>; +} + +impl ClientSnapshotsExt for Client { + fn snapshot_view_by_id(&self) -> builder::SnapshotViewById<'_> { + builder::SnapshotViewById::new(self) + } + + fn snapshot_list(&self) -> builder::SnapshotList<'_> { + builder::SnapshotList::new(self) + } + + fn snapshot_create(&self) -> builder::SnapshotCreate<'_> { + builder::SnapshotCreate::new(self) + } + + fn snapshot_view(&self) -> builder::SnapshotView<'_> { + builder::SnapshotView::new(self) + } + + fn snapshot_delete(&self) -> builder::SnapshotDelete<'_> { + builder::SnapshotDelete::new(self) + } +} + +///Internal system information +pub trait ClientSystemExt { + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + /// + ///```ignore + /// let response = client.system_image_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn system_image_view_by_id(&self) -> builder::SystemImageViewById<'_>; + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + /// + ///```ignore + /// let response = client.ip_pool_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById<'_>; + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + /// + ///```ignore + /// let response = client.silo_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn silo_view_by_id(&self) -> builder::SiloViewById<'_>; + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.certificate_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn certificate_list(&self) -> builder::CertificateList<'_>; + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + /// + ///```ignore + /// let response = client.certificate_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn certificate_create(&self) -> builder::CertificateCreate<'_>; + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_view() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + fn certificate_view(&self) -> builder::CertificateView<'_>; + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + /// + ///```ignore + /// let response = client.certificate_delete() + /// .certificate(certificate) + /// .send() + /// .await; + /// ``` + fn certificate_delete(&self) -> builder::CertificateDelete<'_>; + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.physical_disk_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn physical_disk_list(&self) -> builder::PhysicalDiskList<'_>; + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.rack_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn rack_list(&self) -> builder::RackList<'_>; + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + ///```ignore + /// let response = client.rack_view() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + fn rack_view(&self) -> builder::RackView<'_>; + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sled_list(&self) -> builder::SledList<'_>; + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + ///```ignore + /// let response = client.sled_view() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + fn sled_view(&self) -> builder::SledView<'_>; + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.sled_physical_disk_list() + /// .sled_id(sled_id) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList<'_>; + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_image_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_image_list(&self) -> builder::SystemImageList<'_>; + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + /// + ///```ignore + /// let response = client.system_image_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_image_create(&self) -> builder::SystemImageCreate<'_>; + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_view() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn system_image_view(&self) -> builder::SystemImageView<'_>; + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + /// + ///```ignore + /// let response = client.system_image_delete() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn system_image_delete(&self) -> builder::SystemImageDelete<'_>; + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.ip_pool_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn ip_pool_list(&self) -> builder::IpPoolList<'_>; + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + /// + ///```ignore + /// let response = client.ip_pool_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_create(&self) -> builder::IpPoolCreate<'_>; + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_view() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + fn ip_pool_view(&self) -> builder::IpPoolView<'_>; + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_update() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_update(&self) -> builder::IpPoolUpdate<'_>; + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + /// + ///```ignore + /// let response = client.ip_pool_delete() + /// .pool_name(pool_name) + /// .send() + /// .await; + /// ``` + fn ip_pool_delete(&self) -> builder::IpPoolDelete<'_>; + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_range_list() + /// .pool_name(pool_name) + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_list(&self) -> builder::IpPoolRangeList<'_>; + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_range_add() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd<'_>; + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_range_remove() + /// .pool_name(pool_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove<'_>; + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + /// + ///```ignore + /// let response = client.ip_pool_service_view() + /// .send() + /// .await; + /// ``` + fn ip_pool_service_view(&self) -> builder::IpPoolServiceView<'_>; + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + ///```ignore + /// let response = client.ip_pool_service_range_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList<'_>; + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + /// + ///```ignore + /// let response = client.ip_pool_service_range_add() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd<'_>; + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + /// + ///```ignore + /// let response = client.ip_pool_service_range_remove() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove<'_>; + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + ///```ignore + /// let response = client.system_metric() + /// .metric_name(metric_name) + /// .end_time(end_time) + /// .id(id) + /// .limit(limit) + /// .page_token(page_token) + /// .start_time(start_time) + /// .send() + /// .await; + /// ``` + fn system_metric(&self) -> builder::SystemMetric<'_>; + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.saga_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn saga_list(&self) -> builder::SagaList<'_>; + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + /// + ///```ignore + /// let response = client.saga_view() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + fn saga_view(&self) -> builder::SagaView<'_>; + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_list(&self) -> builder::SiloList<'_>; + ///Create a silo + /// + ///Sends a `POST` request to `/system/silos` + /// + ///```ignore + /// let response = client.silo_create() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silo_create(&self) -> builder::SiloCreate<'_>; + ///Fetch a silo + /// + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_view(&self) -> builder::SiloView<'_>; + ///Delete a silo + /// + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_delete() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_delete(&self) -> builder::SiloDelete<'_>; + ///List a silo's IDPs + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_identity_provider_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList<'_>; + ///Create a user + /// + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.local_idp_user_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate<'_>; + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.local_idp_user_delete() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete<'_>; + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + ///```ignore + /// let response = client.local_idp_user_set_password() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword<'_>; + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.saml_identity_provider_create() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate<'_>; + ///Fetch a SAML IDP + /// + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `provider_name`: The SAML identity provider's name + ///```ignore + /// let response = client.saml_identity_provider_view() + /// .silo_name(silo_name) + /// .provider_name(provider_name) + /// .send() + /// .await; + /// ``` + fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView<'_>; + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + ///```ignore + /// let response = client.silo_policy_view() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silo_policy_view(&self) -> builder::SiloPolicyView<'_>; + ///Update a silo's IAM policy + /// + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + ///```ignore + /// let response = client.silo_policy_update() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silo_policy_update(&self) -> builder::SiloPolicyUpdate<'_>; + ///List users in a silo + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.silo_users_list() + /// .silo_name(silo_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silo_users_list(&self) -> builder::SiloUsersList<'_>; + ///Fetch a user + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + ///```ignore + /// let response = client.silo_user_view() + /// .silo_name(silo_name) + /// .user_id(user_id) + /// .send() + /// .await; + /// ``` + fn silo_user_view(&self) -> builder::SiloUserView<'_>; + ///List built-in users + /// + ///Sends a `GET` request to `/system/user` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_user_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_user_list(&self) -> builder::SystemUserList<'_>; + ///Fetch a built-in user + /// + ///Sends a `GET` request to `/system/user/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. + ///```ignore + /// let response = client.system_user_view() + /// .user_name(user_name) + /// .send() + /// .await; + /// ``` + fn system_user_view(&self) -> builder::SystemUserView<'_>; + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_component_version_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_component_version_list(&self) -> builder::SystemComponentVersionList<'_>; + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.update_deployments_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn update_deployments_list(&self) -> builder::UpdateDeploymentsList<'_>; + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + /// + ///```ignore + /// let response = client.update_deployment_view() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn update_deployment_view(&self) -> builder::UpdateDeploymentView<'_>; + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + /// + ///```ignore + /// let response = client.system_update_refresh() + /// .send() + /// .await; + /// ``` + fn system_update_refresh(&self) -> builder::SystemUpdateRefresh<'_>; + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + /// + ///```ignore + /// let response = client.system_update_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_update_start(&self) -> builder::SystemUpdateStart<'_>; + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + /// + ///```ignore + /// let response = client.system_update_stop() + /// .send() + /// .await; + /// ``` + fn system_update_stop(&self) -> builder::SystemUpdateStop<'_>; + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.system_update_list() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn system_update_list(&self) -> builder::SystemUpdateList<'_>; + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + /// + ///```ignore + /// let response = client.system_update_view() + /// .version(version) + /// .send() + /// .await; + /// ``` + fn system_update_view(&self) -> builder::SystemUpdateView<'_>; + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + /// + ///```ignore + /// let response = client.system_update_components_list() + /// .version(version) + /// .send() + /// .await; + /// ``` + fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList<'_>; + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + /// + ///```ignore + /// let response = client.system_version() + /// .send() + /// .await; + /// ``` + fn system_version(&self) -> builder::SystemVersion<'_>; +} + +impl ClientSystemExt for Client { + fn system_image_view_by_id(&self) -> builder::SystemImageViewById<'_> { + builder::SystemImageViewById::new(self) + } + + fn ip_pool_view_by_id(&self) -> builder::IpPoolViewById<'_> { + builder::IpPoolViewById::new(self) + } + + fn silo_view_by_id(&self) -> builder::SiloViewById<'_> { + builder::SiloViewById::new(self) + } + + fn certificate_list(&self) -> builder::CertificateList<'_> { + builder::CertificateList::new(self) + } + + fn certificate_create(&self) -> builder::CertificateCreate<'_> { + builder::CertificateCreate::new(self) + } + + fn certificate_view(&self) -> builder::CertificateView<'_> { + builder::CertificateView::new(self) + } + + fn certificate_delete(&self) -> builder::CertificateDelete<'_> { + builder::CertificateDelete::new(self) + } + + fn physical_disk_list(&self) -> builder::PhysicalDiskList<'_> { + builder::PhysicalDiskList::new(self) + } + + fn rack_list(&self) -> builder::RackList<'_> { + builder::RackList::new(self) + } + + fn rack_view(&self) -> builder::RackView<'_> { + builder::RackView::new(self) + } + + fn sled_list(&self) -> builder::SledList<'_> { + builder::SledList::new(self) + } + + fn sled_view(&self) -> builder::SledView<'_> { + builder::SledView::new(self) + } + + fn sled_physical_disk_list(&self) -> builder::SledPhysicalDiskList<'_> { + builder::SledPhysicalDiskList::new(self) + } + + fn system_image_list(&self) -> builder::SystemImageList<'_> { + builder::SystemImageList::new(self) + } + + fn system_image_create(&self) -> builder::SystemImageCreate<'_> { + builder::SystemImageCreate::new(self) + } + + fn system_image_view(&self) -> builder::SystemImageView<'_> { + builder::SystemImageView::new(self) + } + + fn system_image_delete(&self) -> builder::SystemImageDelete<'_> { + builder::SystemImageDelete::new(self) + } + + fn ip_pool_list(&self) -> builder::IpPoolList<'_> { + builder::IpPoolList::new(self) + } + + fn ip_pool_create(&self) -> builder::IpPoolCreate<'_> { + builder::IpPoolCreate::new(self) + } + + fn ip_pool_view(&self) -> builder::IpPoolView<'_> { + builder::IpPoolView::new(self) + } + + fn ip_pool_update(&self) -> builder::IpPoolUpdate<'_> { + builder::IpPoolUpdate::new(self) + } + + fn ip_pool_delete(&self) -> builder::IpPoolDelete<'_> { + builder::IpPoolDelete::new(self) + } + + fn ip_pool_range_list(&self) -> builder::IpPoolRangeList<'_> { + builder::IpPoolRangeList::new(self) + } + + fn ip_pool_range_add(&self) -> builder::IpPoolRangeAdd<'_> { + builder::IpPoolRangeAdd::new(self) + } + + fn ip_pool_range_remove(&self) -> builder::IpPoolRangeRemove<'_> { + builder::IpPoolRangeRemove::new(self) + } + + fn ip_pool_service_view(&self) -> builder::IpPoolServiceView<'_> { + builder::IpPoolServiceView::new(self) + } + + fn ip_pool_service_range_list(&self) -> builder::IpPoolServiceRangeList<'_> { + builder::IpPoolServiceRangeList::new(self) + } + + fn ip_pool_service_range_add(&self) -> builder::IpPoolServiceRangeAdd<'_> { + builder::IpPoolServiceRangeAdd::new(self) + } + + fn ip_pool_service_range_remove(&self) -> builder::IpPoolServiceRangeRemove<'_> { + builder::IpPoolServiceRangeRemove::new(self) + } + + fn system_metric(&self) -> builder::SystemMetric<'_> { + builder::SystemMetric::new(self) + } + + fn saga_list(&self) -> builder::SagaList<'_> { + builder::SagaList::new(self) + } + + fn saga_view(&self) -> builder::SagaView<'_> { + builder::SagaView::new(self) + } + + fn silo_list(&self) -> builder::SiloList<'_> { + builder::SiloList::new(self) + } + + fn silo_create(&self) -> builder::SiloCreate<'_> { + builder::SiloCreate::new(self) + } + + fn silo_view(&self) -> builder::SiloView<'_> { + builder::SiloView::new(self) + } + + fn silo_delete(&self) -> builder::SiloDelete<'_> { + builder::SiloDelete::new(self) + } + + fn silo_identity_provider_list(&self) -> builder::SiloIdentityProviderList<'_> { + builder::SiloIdentityProviderList::new(self) + } + + fn local_idp_user_create(&self) -> builder::LocalIdpUserCreate<'_> { + builder::LocalIdpUserCreate::new(self) + } + + fn local_idp_user_delete(&self) -> builder::LocalIdpUserDelete<'_> { + builder::LocalIdpUserDelete::new(self) + } + + fn local_idp_user_set_password(&self) -> builder::LocalIdpUserSetPassword<'_> { + builder::LocalIdpUserSetPassword::new(self) + } + + fn saml_identity_provider_create(&self) -> builder::SamlIdentityProviderCreate<'_> { + builder::SamlIdentityProviderCreate::new(self) + } + + fn saml_identity_provider_view(&self) -> builder::SamlIdentityProviderView<'_> { + builder::SamlIdentityProviderView::new(self) + } + + fn silo_policy_view(&self) -> builder::SiloPolicyView<'_> { + builder::SiloPolicyView::new(self) + } + + fn silo_policy_update(&self) -> builder::SiloPolicyUpdate<'_> { + builder::SiloPolicyUpdate::new(self) + } + + fn silo_users_list(&self) -> builder::SiloUsersList<'_> { + builder::SiloUsersList::new(self) + } + + fn silo_user_view(&self) -> builder::SiloUserView<'_> { + builder::SiloUserView::new(self) + } + + fn system_user_list(&self) -> builder::SystemUserList<'_> { + builder::SystemUserList::new(self) + } + + fn system_user_view(&self) -> builder::SystemUserView<'_> { + builder::SystemUserView::new(self) + } + + fn system_component_version_list(&self) -> builder::SystemComponentVersionList<'_> { + builder::SystemComponentVersionList::new(self) + } + + fn update_deployments_list(&self) -> builder::UpdateDeploymentsList<'_> { + builder::UpdateDeploymentsList::new(self) + } + + fn update_deployment_view(&self) -> builder::UpdateDeploymentView<'_> { + builder::UpdateDeploymentView::new(self) + } + + fn system_update_refresh(&self) -> builder::SystemUpdateRefresh<'_> { + builder::SystemUpdateRefresh::new(self) + } + + fn system_update_start(&self) -> builder::SystemUpdateStart<'_> { + builder::SystemUpdateStart::new(self) + } + + fn system_update_stop(&self) -> builder::SystemUpdateStop<'_> { + builder::SystemUpdateStop::new(self) + } + + fn system_update_list(&self) -> builder::SystemUpdateList<'_> { + builder::SystemUpdateList::new(self) + } + + fn system_update_view(&self) -> builder::SystemUpdateView<'_> { + builder::SystemUpdateView::new(self) + } + + fn system_update_components_list(&self) -> builder::SystemUpdateComponentsList<'_> { + builder::SystemUpdateComponentsList::new(self) + } + + fn system_version(&self) -> builder::SystemVersion<'_> { + builder::SystemVersion::new(self) + } +} + +///A Virtual Private Cloud (VPC) is an isolated network environment that should +/// probaby be moved into a more generic networking tag +pub trait ClientVpcsExt { + ///Fetch a route by id + /// + ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` + /// + ///```ignore + /// let response = client.vpc_router_route_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_view_by_id(&self) -> builder::VpcRouterRouteViewById<'_>; + ///Get a router by id + /// + ///Sends a `GET` request to `/by-id/vpc-routers/{id}` + /// + ///```ignore + /// let response = client.vpc_router_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn vpc_router_view_by_id(&self) -> builder::VpcRouterViewById<'_>; + ///Fetch a subnet by id + /// + ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` + /// + ///```ignore + /// let response = client.vpc_subnet_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_view_by_id(&self) -> builder::VpcSubnetViewById<'_>; + ///Fetch a VPC + /// + ///Sends a `GET` request to `/by-id/vpcs/{id}` + /// + ///```ignore + /// let response = client.vpc_view_by_id() + /// .id(id) + /// .send() + /// .await; + /// ``` + fn vpc_view_by_id(&self) -> builder::VpcViewById<'_>; + ///List VPCs + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn vpc_list(&self) -> builder::VpcList<'_>; + ///Create a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + ///```ignore + /// let response = client.vpc_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_create(&self) -> builder::VpcCreate<'_>; + ///Fetch a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn vpc_view(&self) -> builder::VpcView<'_>; + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_update(&self) -> builder::VpcUpdate<'_>; + ///Delete a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + /// + ///```ignore + /// let response = client.vpc_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn vpc_delete(&self) -> builder::VpcDelete<'_>; + ///List firewall rules + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + /// + ///```ignore + /// let response = client.vpc_firewall_rules_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn vpc_firewall_rules_view(&self) -> builder::VpcFirewallRulesView<'_>; + ///Replace firewall rules + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + /// + ///```ignore + /// let response = client.vpc_firewall_rules_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_firewall_rules_update(&self) -> builder::VpcFirewallRulesUpdate<'_>; + ///List routers + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_router_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn vpc_router_list(&self) -> builder::VpcRouterList<'_>; + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + /// + ///```ignore + /// let response = client.vpc_router_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_router_create(&self) -> builder::VpcRouterCreate<'_>; + ///Get a router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + fn vpc_router_view(&self) -> builder::VpcRouterView<'_>; + ///Update a router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_router_update(&self) -> builder::VpcRouterUpdate<'_>; + ///Delete a router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + /// + ///```ignore + /// let response = client.vpc_router_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + fn vpc_router_delete(&self) -> builder::VpcRouterDelete<'_>; + ///List routes + /// + ///List the routes associated with a router in a particular VPC. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `router_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_router_route_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_list(&self) -> builder::VpcRouterRouteList<'_>; + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + /// + ///```ignore + /// let response = client.vpc_router_route_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_create(&self) -> builder::VpcRouterRouteCreate<'_>; + ///Fetch a route + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_view(&self) -> builder::VpcRouterRouteView<'_>; + ///Update a route + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_update(&self) -> builder::VpcRouterRouteUpdate<'_>; + ///Delete a route + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + /// + ///```ignore + /// let response = client.vpc_router_route_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + fn vpc_router_route_delete(&self) -> builder::VpcRouterRouteDelete<'_>; + ///List subnets + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_subnet_list() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_list(&self) -> builder::VpcSubnetList<'_>; + ///Create a subnet + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + /// + ///```ignore + /// let response = client.vpc_subnet_create() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_create(&self) -> builder::VpcSubnetCreate<'_>; + ///Fetch a subnet + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_view() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_view(&self) -> builder::VpcSubnetView<'_>; + ///Update a subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_update() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_update(&self) -> builder::VpcSubnetUpdate<'_>; + ///Delete a subnet + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + /// + ///```ignore + /// let response = client.vpc_subnet_delete() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_delete(&self) -> builder::VpcSubnetDelete<'_>; + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `subnet_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + ///```ignore + /// let response = client.vpc_subnet_list_network_interfaces() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn vpc_subnet_list_network_interfaces(&self) -> builder::VpcSubnetListNetworkInterfaces<'_>; +} + +impl ClientVpcsExt for Client { + fn vpc_router_route_view_by_id(&self) -> builder::VpcRouterRouteViewById<'_> { + builder::VpcRouterRouteViewById::new(self) + } + + fn vpc_router_view_by_id(&self) -> builder::VpcRouterViewById<'_> { + builder::VpcRouterViewById::new(self) + } + + fn vpc_subnet_view_by_id(&self) -> builder::VpcSubnetViewById<'_> { + builder::VpcSubnetViewById::new(self) + } + + fn vpc_view_by_id(&self) -> builder::VpcViewById<'_> { + builder::VpcViewById::new(self) + } + + fn vpc_list(&self) -> builder::VpcList<'_> { + builder::VpcList::new(self) + } + + fn vpc_create(&self) -> builder::VpcCreate<'_> { + builder::VpcCreate::new(self) + } + + fn vpc_view(&self) -> builder::VpcView<'_> { + builder::VpcView::new(self) + } + + fn vpc_update(&self) -> builder::VpcUpdate<'_> { + builder::VpcUpdate::new(self) + } + + fn vpc_delete(&self) -> builder::VpcDelete<'_> { + builder::VpcDelete::new(self) + } + + fn vpc_firewall_rules_view(&self) -> builder::VpcFirewallRulesView<'_> { + builder::VpcFirewallRulesView::new(self) + } + + fn vpc_firewall_rules_update(&self) -> builder::VpcFirewallRulesUpdate<'_> { + builder::VpcFirewallRulesUpdate::new(self) + } + + fn vpc_router_list(&self) -> builder::VpcRouterList<'_> { + builder::VpcRouterList::new(self) + } + + fn vpc_router_create(&self) -> builder::VpcRouterCreate<'_> { + builder::VpcRouterCreate::new(self) + } + + fn vpc_router_view(&self) -> builder::VpcRouterView<'_> { + builder::VpcRouterView::new(self) + } + + fn vpc_router_update(&self) -> builder::VpcRouterUpdate<'_> { + builder::VpcRouterUpdate::new(self) + } + + fn vpc_router_delete(&self) -> builder::VpcRouterDelete<'_> { + builder::VpcRouterDelete::new(self) + } + + fn vpc_router_route_list(&self) -> builder::VpcRouterRouteList<'_> { + builder::VpcRouterRouteList::new(self) + } + + fn vpc_router_route_create(&self) -> builder::VpcRouterRouteCreate<'_> { + builder::VpcRouterRouteCreate::new(self) + } + + fn vpc_router_route_view(&self) -> builder::VpcRouterRouteView<'_> { + builder::VpcRouterRouteView::new(self) + } + + fn vpc_router_route_update(&self) -> builder::VpcRouterRouteUpdate<'_> { + builder::VpcRouterRouteUpdate::new(self) + } + + fn vpc_router_route_delete(&self) -> builder::VpcRouterRouteDelete<'_> { + builder::VpcRouterRouteDelete::new(self) + } + + fn vpc_subnet_list(&self) -> builder::VpcSubnetList<'_> { + builder::VpcSubnetList::new(self) + } + + fn vpc_subnet_create(&self) -> builder::VpcSubnetCreate<'_> { + builder::VpcSubnetCreate::new(self) + } + + fn vpc_subnet_view(&self) -> builder::VpcSubnetView<'_> { + builder::VpcSubnetView::new(self) + } + + fn vpc_subnet_update(&self) -> builder::VpcSubnetUpdate<'_> { + builder::VpcSubnetUpdate::new(self) + } + + fn vpc_subnet_delete(&self) -> builder::VpcSubnetDelete<'_> { + builder::VpcSubnetDelete::new(self) + } + + fn vpc_subnet_list_network_interfaces(&self) -> builder::VpcSubnetListNetworkInterfaces<'_> { + builder::VpcSubnetListNetworkInterfaces::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`ClientDisksExt::disk_view_by_id`] + /// + ///[`ClientDisksExt::disk_view_by_id`]: super::ClientDisksExt::disk_view_by_id + #[derive(Debug, Clone)] + pub struct DiskViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> DiskViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/disks/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/disks/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientImagesExt::image_view_by_id`] + /// + ///[`ClientImagesExt::image_view_by_id`]: super::ClientImagesExt::image_view_by_id + #[derive(Debug, Clone)] + pub struct ImageViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> ImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_view_by_id`] + /// + ///[`ClientInstancesExt::instance_view_by_id`]: super::ClientInstancesExt::instance_view_by_id + #[derive(Debug, Clone)] + pub struct InstanceViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/instances/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/instances/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for + /// [`ClientInstancesExt::instance_network_interface_view_by_id`] + /// + ///[`ClientInstancesExt::instance_network_interface_view_by_id`]: super::ClientInstancesExt::instance_network_interface_view_by_id + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceNetworkInterfaceViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/network-interfaces/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/network-interfaces/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_view_by_id`] + /// + ///[`ClientOrganizationsExt::organization_view_by_id`]: super::ClientOrganizationsExt::organization_view_by_id + #[derive(Debug, Clone)] + pub struct OrganizationViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> OrganizationViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/organizations/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/organizations/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_view_by_id`] + /// + ///[`ClientProjectsExt::project_view_by_id`]: super::ClientProjectsExt::project_view_by_id + #[derive(Debug, Clone)] + pub struct ProjectViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> ProjectViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/projects/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/projects/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSnapshotsExt::snapshot_view_by_id`] + /// + ///[`ClientSnapshotsExt::snapshot_view_by_id`]: super::ClientSnapshotsExt::snapshot_view_by_id + #[derive(Debug, Clone)] + pub struct SnapshotViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SnapshotViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/snapshots/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/snapshots/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_view_by_id`] + /// + ///[`ClientVpcsExt::vpc_router_route_view_by_id`]: super::ClientVpcsExt::vpc_router_route_view_by_id + #[derive(Debug, Clone)] + pub struct VpcRouterRouteViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcRouterRouteViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-router-routes/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_view_by_id`] + /// + ///[`ClientVpcsExt::vpc_router_view_by_id`]: super::ClientVpcsExt::vpc_router_view_by_id + #[derive(Debug, Clone)] + pub struct VpcRouterViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcRouterViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-routers/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-routers/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_view_by_id`] + /// + ///[`ClientVpcsExt::vpc_subnet_view_by_id`]: super::ClientVpcsExt::vpc_subnet_view_by_id + #[derive(Debug, Clone)] + pub struct VpcSubnetViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcSubnetViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpc-subnets/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_view_by_id`] + /// + ///[`ClientVpcsExt::vpc_view_by_id`]: super::ClientVpcsExt::vpc_view_by_id + #[derive(Debug, Clone)] + pub struct VpcViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> VpcViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/by-id/vpcs/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/by-id/vpcs/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::device_auth_request`] + /// + ///[`ClientHiddenExt::device_auth_request`]: super::ClientHiddenExt::device_auth_request + #[derive(Debug, Clone)] + pub struct DeviceAuthRequest<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAuthRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DeviceAuthRequest` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthRequest, + ) -> types::builder::DeviceAuthRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/auth` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::DeviceAuthRequest::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/auth", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_auth_request", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`ClientHiddenExt::device_auth_confirm`] + /// + ///[`ClientHiddenExt::device_auth_confirm`]: super::ClientHiddenExt::device_auth_confirm + #[derive(Debug, Clone)] + pub struct DeviceAuthConfirm<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAuthConfirm<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DeviceAuthVerify` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthVerify, + ) -> types::builder::DeviceAuthVerify, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/confirm` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::DeviceAuthVerify::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/confirm", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "device_auth_confirm", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::device_access_token`] + /// + ///[`ClientHiddenExt::device_access_token`]: super::ClientHiddenExt::device_access_token + #[derive(Debug, Clone)] + pub struct DeviceAccessToken<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> DeviceAccessToken<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `DeviceAccessTokenRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAccessTokenRequest, + ) -> types::builder::DeviceAccessTokenRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/device/token` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::DeviceAccessTokenRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/device/token", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_access_token", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`ClientSilosExt::group_list`] + /// + ///[`ClientSilosExt::group_list`]: super::ClientSilosExt::group_list + #[derive(Debug, Clone)] + pub struct GroupList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> GroupList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/groups` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/groups", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "group_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/groups` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientHiddenExt::login_spoof`] + /// + ///[`ClientHiddenExt::login_spoof`]: super::ClientHiddenExt::login_spoof + #[derive(Debug, Clone)] + pub struct LoginSpoof<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> LoginSpoof<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SpoofLoginBody` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SpoofLoginBody) -> types::builder::SpoofLoginBody, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/login` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SpoofLoginBody::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/login", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_spoof", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientLoginExt::login_local`] + /// + ///[`ClientLoginExt::login_local`]: super::ClientLoginExt::login_local + #[derive(Debug, Clone)] + pub struct LoginLocal<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LoginLocal<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `UsernamePasswordCredentials` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::UsernamePasswordCredentials, + ) -> types::builder::UsernamePasswordCredentials, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::UsernamePasswordCredentials::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/local", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_local", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientLoginExt::login_saml_begin`] + /// + ///[`ClientLoginExt::login_saml_begin`]: super::ClientLoginExt::login_saml_begin + #[derive(Debug, Clone)] + pub struct LoginSamlBegin<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> LoginSamlBegin<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "login_saml_begin", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientLoginExt::login_saml`] + /// + ///[`ClientLoginExt::login_saml`]: super::ClientLoginExt::login_saml + #[derive(Debug)] + pub struct LoginSaml<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + body: Result<::wasm_bindgen::JsValue, String>, + } + + impl<'a> LoginSaml<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + pub fn body(mut self, value: B) -> Self + where + B: std::convert::TryInto<::wasm_bindgen::JsValue>, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `wasm_bindgen::JsValue` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/login/{}/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", super::Client::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "login_saml", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::logout`] + /// + ///[`ClientHiddenExt::logout`]: super::ClientHiddenExt::logout + #[derive(Debug, Clone)] + pub struct Logout<'a> { + client: &'a super::Client, + } + + impl<'a> Logout<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/logout` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/logout", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "logout", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_list`] + /// + ///[`ClientOrganizationsExt::organization_list`]: super::ClientOrganizationsExt::organization_list + #[derive(Debug, Clone)] + pub struct OrganizationList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientOrganizationsExt::organization_create`] + /// + ///[`ClientOrganizationsExt::organization_create`]: super::ClientOrganizationsExt::organization_create + #[derive(Debug, Clone)] + pub struct OrganizationCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::OrganizationCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_view`] + /// + ///[`ClientOrganizationsExt::organization_view`]: super::ClientOrganizationsExt::organization_view + #[derive(Debug, Clone)] + pub struct OrganizationView<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_update`] + /// + ///[`ClientOrganizationsExt::organization_update`]: super::ClientOrganizationsExt::organization_update + #[derive(Debug, Clone)] + pub struct OrganizationUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> OrganizationUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_delete`] + /// + ///[`ClientOrganizationsExt::organization_delete`]: super::ClientOrganizationsExt::organization_delete + #[derive(Debug, Clone)] + pub struct OrganizationDelete<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/organizations/{organization_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_view`] + /// + ///[`ClientOrganizationsExt::organization_policy_view`]: super::ClientOrganizationsExt::organization_policy_view + #[derive(Debug, Clone)] + pub struct OrganizationPolicyView<'a> { + client: &'a super::Client, + organization_name: Result, + } + + impl<'a> OrganizationPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_update`] + /// + ///[`ClientOrganizationsExt::organization_policy_update`]: super::ClientOrganizationsExt::organization_policy_update + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_list`] + /// + ///[`ClientProjectsExt::project_list`]: super::ClientProjectsExt::project_list + #[derive(Debug, Clone)] + pub struct ProjectList<'a> { + client: &'a super::Client, + organization_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientProjectsExt::project_create`] + /// + ///[`ClientProjectsExt::project_create`]: super::ClientProjectsExt::project_create + #[derive(Debug, Clone)] + pub struct ProjectCreate<'a> { + client: &'a super::Client, + organization_name: Result, + body: Result, + } + + impl<'a> ProjectCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_view`] + /// + ///[`ClientProjectsExt::project_view`]: super::ClientProjectsExt::project_view + #[derive(Debug, Clone)] + pub struct ProjectView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_update`] + /// + ///[`ClientProjectsExt::project_update`]: super::ClientProjectsExt::project_update + #[derive(Debug, Clone)] + pub struct ProjectUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ProjectUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_delete`] + /// + ///[`ClientProjectsExt::project_delete`]: super::ClientProjectsExt::project_delete + #[derive(Debug, Clone)] + pub struct ProjectDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_list`] + /// + ///[`ClientDisksExt::disk_list`]: super::ClientDisksExt::disk_list + #[derive(Debug, Clone)] + pub struct DiskList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientDisksExt::disk_create`] + /// + ///[`ClientDisksExt::disk_create`]: super::ClientDisksExt::disk_create + #[derive(Debug, Clone)] + pub struct DiskCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> DiskCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_view`] + /// + ///[`ClientDisksExt::disk_view`]: super::ClientDisksExt::disk_view + #[derive(Debug, Clone)] + pub struct DiskView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + } + + impl<'a> DiskView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_delete`] + /// + ///[`ClientDisksExt::disk_delete`]: super::ClientDisksExt::disk_delete + #[derive(Debug, Clone)] + pub struct DiskDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + } + + impl<'a> DiskDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_metrics_list`] + /// + ///[`ClientDisksExt::disk_metrics_list`]: super::ClientDisksExt::disk_metrics_list + #[derive(Debug, Clone)] + pub struct DiskMetricsList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + disk_name: Result, + metric_name: Result, + end_time: Result>, String>, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> DiskMetricsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + disk_name: Err("disk_name was not initialized".to_string()), + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn disk_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk_name = value + .try_into() + .map_err(|_| "conversion to `Name` for disk_name failed".to_string()); + self + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `DiskMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.end_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end_time \ + failed" + .to_string() + }); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.start_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for \ + start_time failed" + .to_string() + }); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + disk_name, + metric_name, + end_time, + limit, + page_token, + start_time, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let disk_name = disk_name.map_err(Error::InvalidRequest)?; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}/metrics/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_metrics_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + end_time: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientImagesExt::image_list`] + /// + ///[`ClientImagesExt::image_list`]: super::ClientImagesExt::image_list + #[derive(Debug, Clone)] + pub struct ImageList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientImagesExt::image_create`] + /// + ///[`ClientImagesExt::image_create`]: super::ClientImagesExt::image_create + #[derive(Debug, Clone)] + pub struct ImageCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ImageCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ImageCreate) -> types::builder::ImageCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ImageCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "image_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientImagesExt::image_view`] + /// + ///[`ClientImagesExt::image_view`]: super::ClientImagesExt::image_view + #[derive(Debug, Clone)] + pub struct ImageView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + image_name: Result, + } + + impl<'a> ImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + image_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientImagesExt::image_delete`] + /// + ///[`ClientImagesExt::image_delete`]: super::ClientImagesExt::image_delete + #[derive(Debug, Clone)] + pub struct ImageDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + image_name: Result, + } + + impl<'a> ImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + image_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_list`] + /// + ///[`ClientInstancesExt::instance_list`]: super::ClientInstancesExt::instance_list + #[derive(Debug, Clone)] + pub struct InstanceList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientInstancesExt::instance_create`] + /// + ///[`ClientInstancesExt::instance_create`]: super::ClientInstancesExt::instance_create + #[derive(Debug, Clone)] + pub struct InstanceCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> InstanceCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_view`] + /// + ///[`ClientInstancesExt::instance_view`]: super::ClientInstancesExt::instance_view + #[derive(Debug, Clone)] + pub struct InstanceView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_delete`] + /// + ///[`ClientInstancesExt::instance_delete`]: super::ClientInstancesExt::instance_delete + #[derive(Debug, Clone)] + pub struct InstanceDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_list`] + /// + ///[`ClientInstancesExt::instance_disk_list`]: super::ClientInstancesExt::instance_disk_list + #[derive(Debug, Clone)] + pub struct InstanceDiskList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_attach`] + /// + ///[`ClientInstancesExt::instance_disk_attach`]: super::ClientInstancesExt::instance_disk_attach + #[derive(Debug, Clone)] + pub struct InstanceDiskAttach<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceDiskAttach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskIdentifier::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/attach", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_detach`] + /// + ///[`ClientInstancesExt::instance_disk_detach`]: super::ClientInstancesExt::instance_disk_detach + #[derive(Debug, Clone)] + pub struct InstanceDiskDetach<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceDiskDetach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskIdentifier` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskIdentifier::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/detach", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_external_ip_list`] + /// + ///[`ClientInstancesExt::instance_external_ip_list`]: super::ClientInstancesExt::instance_external_ip_list + #[derive(Debug, Clone)] + pub struct InstanceExternalIpList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceExternalIpList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/external-ips` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/external-ips", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_external_ip_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_migrate`] + /// + ///[`ClientInstancesExt::instance_migrate`]: super::ClientInstancesExt::instance_migrate + #[derive(Debug, Clone)] + pub struct InstanceMigrate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceMigrate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceMigrate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/migrate", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interface_list`] + /// + ///[`ClientInstancesExt::instance_network_interface_list`]: super::ClientInstancesExt::instance_network_interface_list + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceNetworkInterfaceList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + organization_name, + project_name, + instance_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interface_create`] + /// + ///[`ClientInstancesExt::instance_network_interface_create`]: super::ClientInstancesExt::instance_network_interface_create + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + body: Result, + } + + impl<'a> InstanceNetworkInterfaceCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceCreate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceCreate, + ) -> types::builder::NetworkInterfaceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::NetworkInterfaceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interface_view`] + /// + ///[`ClientInstancesExt::instance_network_interface_view`]: super::ClientInstancesExt::instance_network_interface_view + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + } + + impl<'a> InstanceNetworkInterfaceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interface_update`] + /// + ///[`ClientInstancesExt::instance_network_interface_update`]: super::ClientInstancesExt::instance_network_interface_update + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + body: Result, + } + + impl<'a> InstanceNetworkInterfaceUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `NetworkInterfaceUpdate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceUpdate, + ) -> types::builder::NetworkInterfaceUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::NetworkInterfaceUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interface_delete`] + /// + ///[`ClientInstancesExt::instance_network_interface_delete`]: super::ClientInstancesExt::instance_network_interface_delete + #[derive(Debug, Clone)] + pub struct InstanceNetworkInterfaceDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + interface_name: Result, + } + + impl<'a> InstanceNetworkInterfaceDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + interface_name: Err("interface_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn interface_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.interface_name = value + .try_into() + .map_err(|_| "conversion to `Name` for interface_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/network-interfaces/{interface_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + interface_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let interface_name = interface_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_reboot`] + /// + ///[`ClientInstancesExt::instance_reboot`]: super::ClientInstancesExt::instance_reboot + #[derive(Debug, Clone)] + pub struct InstanceReboot<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceReboot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/reboot", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console`] + /// + ///[`ClientInstancesExt::instance_serial_console`]: super::ClientInstancesExt::instance_serial_console + #[derive(Debug, Clone)] + pub struct InstanceSerialConsole<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + } + + impl<'a> InstanceSerialConsole<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for most_recent failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + from_start, + max_bytes, + most_recent, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console_stream`] + /// + ///[`ClientInstancesExt::instance_serial_console_stream`]: super::ClientInstancesExt::instance_serial_console_stream + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStream<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceSerialConsoleStream<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`ClientInstancesExt::instance_start`] + /// + ///[`ClientInstancesExt::instance_start`]: super::ClientInstancesExt::instance_start + #[derive(Debug, Clone)] + pub struct InstanceStart<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/start", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_stop`] + /// + ///[`ClientInstancesExt::instance_stop`]: super::ClientInstancesExt::instance_stop + #[derive(Debug, Clone)] + pub struct InstanceStop<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + instance_name: Result, + } + + impl<'a> InstanceStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + instance_name: Err("instance_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn instance_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance_name = value + .try_into() + .map_err(|_| "conversion to `Name` for instance_name failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// instances/{instance_name}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + instance_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let instance_name = instance_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/stop", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_view`] + /// + ///[`ClientProjectsExt::project_policy_view`]: super::ClientProjectsExt::project_policy_view + #[derive(Debug, Clone)] + pub struct ProjectPolicyView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + } + + impl<'a> ProjectPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_update`] + /// + ///[`ClientProjectsExt::project_policy_update`]: super::ClientProjectsExt::project_policy_update + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> ProjectPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSnapshotsExt::snapshot_list`] + /// + ///[`ClientSnapshotsExt::snapshot_list`]: super::ClientSnapshotsExt::snapshot_list + #[derive(Debug, Clone)] + pub struct SnapshotList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SnapshotList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSnapshotsExt::snapshot_create`] + /// + ///[`ClientSnapshotsExt::snapshot_create`]: super::ClientSnapshotsExt::snapshot_create + #[derive(Debug, Clone)] + pub struct SnapshotCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> SnapshotCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SnapshotCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SnapshotCreate) -> types::builder::SnapshotCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::SnapshotCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "snapshot_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSnapshotsExt::snapshot_view`] + /// + ///[`ClientSnapshotsExt::snapshot_view`]: super::ClientSnapshotsExt::snapshot_view + #[derive(Debug, Clone)] + pub struct SnapshotView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + snapshot_name: Result, + } + + impl<'a> SnapshotView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + snapshot_name: Err("snapshot_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn snapshot_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.snapshot_name = value + .try_into() + .map_err(|_| "conversion to `Name` for snapshot_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots/{snapshot_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + snapshot_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let snapshot_name = snapshot_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSnapshotsExt::snapshot_delete`] + /// + ///[`ClientSnapshotsExt::snapshot_delete`]: super::ClientSnapshotsExt::snapshot_delete + #[derive(Debug, Clone)] + pub struct SnapshotDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + snapshot_name: Result, + } + + impl<'a> SnapshotDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + snapshot_name: Err("snapshot_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn snapshot_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.snapshot_name = value + .try_into() + .map_err(|_| "conversion to `Name` for snapshot_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/ + /// snapshots/{snapshot_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + snapshot_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let snapshot_name = snapshot_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_list`] + /// + ///[`ClientVpcsExt::vpc_list`]: super::ClientVpcsExt::vpc_list + #[derive(Debug, Clone)] + pub struct VpcList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientVpcsExt::vpc_create`] + /// + ///[`ClientVpcsExt::vpc_create`]: super::ClientVpcsExt::vpc_create + #[derive(Debug, Clone)] + pub struct VpcCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + body: Result, + } + + impl<'a> VpcCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcCreate) -> types::builder::VpcCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_view`] + /// + ///[`ClientVpcsExt::vpc_view`]: super::ClientVpcsExt::vpc_view + #[derive(Debug, Clone)] + pub struct VpcView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_update`] + /// + ///[`ClientVpcsExt::vpc_update`]: super::ClientVpcsExt::vpc_update + #[derive(Debug, Clone)] + pub struct VpcUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcUpdate) -> types::builder::VpcUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_delete`] + /// + ///[`ClientVpcsExt::vpc_delete`]: super::ClientVpcsExt::vpc_delete + #[derive(Debug, Clone)] + pub struct VpcDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_firewall_rules_view`] + /// + ///[`ClientVpcsExt::vpc_firewall_rules_view`]: super::ClientVpcsExt::vpc_firewall_rules_view + #[derive(Debug, Clone)] + pub struct VpcFirewallRulesView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + } + + impl<'a> VpcFirewallRulesView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_firewall_rules_update`] + /// + ///[`ClientVpcsExt::vpc_firewall_rules_update`]: super::ClientVpcsExt::vpc_firewall_rules_update + #[derive(Debug, Clone)] + pub struct VpcFirewallRulesUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcFirewallRulesUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `VpcFirewallRuleUpdateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::VpcFirewallRuleUpdateParams, + ) -> types::builder::VpcFirewallRuleUpdateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::VpcFirewallRuleUpdateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_list`] + /// + ///[`ClientVpcsExt::vpc_router_list`]: super::ClientVpcsExt::vpc_router_list + #[derive(Debug, Clone)] + pub struct VpcRouterList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcRouterList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_create`] + /// + ///[`ClientVpcsExt::vpc_router_create`]: super::ClientVpcsExt::vpc_router_create + #[derive(Debug, Clone)] + pub struct VpcRouterCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcRouterCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcRouterCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterCreate) -> types::builder::VpcRouterCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcRouterCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_view`] + /// + ///[`ClientVpcsExt::vpc_router_view`]: super::ClientVpcsExt::vpc_router_view + #[derive(Debug, Clone)] + pub struct VpcRouterView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + } + + impl<'a> VpcRouterView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_update`] + /// + ///[`ClientVpcsExt::vpc_router_update`]: super::ClientVpcsExt::vpc_router_update + #[derive(Debug, Clone)] + pub struct VpcRouterUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + body: Result, + } + + impl<'a> VpcRouterUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcRouterUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterUpdate) -> types::builder::VpcRouterUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcRouterUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_delete`] + /// + ///[`ClientVpcsExt::vpc_router_delete`]: super::ClientVpcsExt::vpc_router_delete + #[derive(Debug, Clone)] + pub struct VpcRouterDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + } + + impl<'a> VpcRouterDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_list`] + /// + ///[`ClientVpcsExt::vpc_router_route_list`]: super::ClientVpcsExt::vpc_router_route_list + #[derive(Debug, Clone)] + pub struct VpcRouterRouteList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcRouterRouteList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_create`] + /// + ///[`ClientVpcsExt::vpc_router_route_create`]: super::ClientVpcsExt::vpc_router_route_create + #[derive(Debug, Clone)] + pub struct VpcRouterRouteCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + body: Result, + } + + impl<'a> VpcRouterRouteCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteCreateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteCreateParams, + ) -> types::builder::RouterRouteCreateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::RouterRouteCreateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_view`] + /// + ///[`ClientVpcsExt::vpc_router_route_view`]: super::ClientVpcsExt::vpc_router_route_view + #[derive(Debug, Clone)] + pub struct VpcRouterRouteView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + } + + impl<'a> VpcRouterRouteView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_update`] + /// + ///[`ClientVpcsExt::vpc_router_route_update`]: super::ClientVpcsExt::vpc_router_route_update + #[derive(Debug, Clone)] + pub struct VpcRouterRouteUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + body: Result, + } + + impl<'a> VpcRouterRouteUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `RouterRouteUpdateParams` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteUpdateParams, + ) -> types::builder::RouterRouteUpdateParams, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::RouterRouteUpdateParams::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_router_route_delete`] + /// + ///[`ClientVpcsExt::vpc_router_route_delete`]: super::ClientVpcsExt::vpc_router_route_delete + #[derive(Debug, Clone)] + pub struct VpcRouterRouteDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + router_name: Result, + route_name: Result, + } + + impl<'a> VpcRouterRouteDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + router_name: Err("router_name was not initialized".to_string()), + route_name: Err("route_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn router_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.router_name = value + .try_into() + .map_err(|_| "conversion to `Name` for router_name failed".to_string()); + self + } + + pub fn route_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.route_name = value + .try_into() + .map_err(|_| "conversion to `Name` for route_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + router_name, + route_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let router_name = router_name.map_err(Error::InvalidRequest)?; + let route_name = route_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_list`] + /// + ///[`ClientVpcsExt::vpc_subnet_list`]: super::ClientVpcsExt::vpc_subnet_list + #[derive(Debug, Clone)] + pub struct VpcSubnetList<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcSubnetList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_create`] + /// + ///[`ClientVpcsExt::vpc_subnet_create`]: super::ClientVpcsExt::vpc_subnet_create + #[derive(Debug, Clone)] + pub struct VpcSubnetCreate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + body: Result, + } + + impl<'a> VpcSubnetCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcSubnetCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetCreate) -> types::builder::VpcSubnetCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcSubnetCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_view`] + /// + ///[`ClientVpcsExt::vpc_subnet_view`]: super::ClientVpcsExt::vpc_subnet_view + #[derive(Debug, Clone)] + pub struct VpcSubnetView<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + } + + impl<'a> VpcSubnetView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_update`] + /// + ///[`ClientVpcsExt::vpc_subnet_update`]: super::ClientVpcsExt::vpc_subnet_update + #[derive(Debug, Clone)] + pub struct VpcSubnetUpdate<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + body: Result, + } + + impl<'a> VpcSubnetUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `VpcSubnetUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetUpdate) -> types::builder::VpcSubnetUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + body, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::VpcSubnetUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_delete`] + /// + ///[`ClientVpcsExt::vpc_subnet_delete`]: super::ClientVpcsExt::vpc_subnet_delete + #[derive(Debug, Clone)] + pub struct VpcSubnetDelete<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + } + + impl<'a> VpcSubnetDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientVpcsExt::vpc_subnet_list_network_interfaces`] + /// + ///[`ClientVpcsExt::vpc_subnet_list_network_interfaces`]: super::ClientVpcsExt::vpc_subnet_list_network_interfaces + #[derive(Debug, Clone)] + pub struct VpcSubnetListNetworkInterfaces<'a> { + client: &'a super::Client, + organization_name: Result, + project_name: Result, + vpc_name: Result, + subnet_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> VpcSubnetListNetworkInterfaces<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization_name: Err("organization_name was not initialized".to_string()), + project_name: Err("project_name was not initialized".to_string()), + vpc_name: Err("vpc_name was not initialized".to_string()), + subnet_name: Err("subnet_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn organization_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization_name = value + .try_into() + .map_err(|_| "conversion to `Name` for organization_name failed".to_string()); + self + } + + pub fn project_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project_name = value + .try_into() + .map_err(|_| "conversion to `Name` for project_name failed".to_string()); + self + } + + pub fn vpc_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.vpc_name = value + .try_into() + .map_err(|_| "conversion to `Name` for vpc_name failed".to_string()); + self + } + + pub fn subnet_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.subnet_name = value + .try_into() + .map_err(|_| "conversion to `Name` for subnet_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + organization_name, + project_name, + vpc_name, + subnet_name, + limit, + page_token, + sort_by, + } = self; + let organization_name = organization_name.map_err(Error::InvalidRequest)?; + let project_name = project_name.map_err(Error::InvalidRequest)?; + let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; + let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}/network-interfaces", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list_network_interfaces", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSilosExt::policy_view`] + /// + ///[`ClientSilosExt::policy_view`]: super::ClientSilosExt::policy_view + #[derive(Debug, Clone)] + pub struct PolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> PolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/policy", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSilosExt::policy_update`] + /// + ///[`ClientSilosExt::policy_update`]: super::ClientSilosExt::policy_update + #[derive(Debug, Clone)] + pub struct PolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> PolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SiloRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/policy", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRolesExt::role_list`] + /// + ///[`ClientRolesExt::role_list`]: super::ClientRolesExt::role_list + #[derive(Debug, Clone)] + pub struct RoleList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> RoleList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/roles` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/roles", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/roles` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientRolesExt::role_view`] + /// + ///[`ClientRolesExt::role_view`]: super::ClientRolesExt::role_view + #[derive(Debug, Clone)] + pub struct RoleView<'a> { + client: &'a super::Client, + role_name: Result<::std::string::String, String>, + } + + impl<'a> RoleView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + role_name: Err("role_name was not initialized".to_string()), + } + } + + pub fn role_name(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.role_name = value.try_into().map_err(|_| { + "conversion to `:: std :: string :: String` for role_name failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/roles/{role_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, role_name } = self; + let role_name = role_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/roles/{}", + client.baseurl, + encode_path(&role_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::session_me`] + /// + ///[`ClientHiddenExt::session_me`]: super::ClientHiddenExt::session_me + #[derive(Debug, Clone)] + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/session/me` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/session/me", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientHiddenExt::session_me_groups`] + /// + ///[`ClientHiddenExt::session_me_groups`]: super::ClientHiddenExt::session_me_groups + #[derive(Debug, Clone)] + pub struct SessionMeGroups<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SessionMeGroups<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/groups` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/groups", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me_groups", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/session/me/groups` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSessionExt::session_sshkey_list`] + /// + ///[`ClientSessionExt::session_sshkey_list`]: super::ClientSessionExt::session_sshkey_list + #[derive(Debug, Clone)] + pub struct SessionSshkeyList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SessionSshkeyList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/sshkeys` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/session/me/sshkeys` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSessionExt::session_sshkey_create`] + /// + ///[`ClientSessionExt::session_sshkey_create`]: super::ClientSessionExt::session_sshkey_create + #[derive(Debug, Clone)] + pub struct SessionSshkeyCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SessionSshkeyCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SshKeyCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SshKeyCreate) -> types::builder::SshKeyCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/session/me/sshkeys` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SshKeyCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "session_sshkey_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSessionExt::session_sshkey_view`] + /// + ///[`ClientSessionExt::session_sshkey_view`]: super::ClientSessionExt::session_sshkey_view + #[derive(Debug, Clone)] + pub struct SessionSshkeyView<'a> { + client: &'a super::Client, + ssh_key_name: Result, + } + + impl<'a> SessionSshkeyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + ssh_key_name: Err("ssh_key_name was not initialized".to_string()), + } + } + + pub fn ssh_key_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.ssh_key_name = value + .try_into() + .map_err(|_| "conversion to `Name` for ssh_key_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + ssh_key_name, + } = self; + let ssh_key_name = ssh_key_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSessionExt::session_sshkey_delete`] + /// + ///[`ClientSessionExt::session_sshkey_delete`]: super::ClientSessionExt::session_sshkey_delete + #[derive(Debug, Clone)] + pub struct SessionSshkeyDelete<'a> { + client: &'a super::Client, + ssh_key_name: Result, + } + + impl<'a> SessionSshkeyDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + ssh_key_name: Err("ssh_key_name was not initialized".to_string()), + } + } + + pub fn ssh_key_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.ssh_key_name = value + .try_into() + .map_err(|_| "conversion to `Name` for ssh_key_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + ssh_key_name, + } = self; + let ssh_key_name = ssh_key_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_image_view_by_id`] + /// + ///[`ClientSystemExt::system_image_view_by_id`]: super::ClientSystemExt::system_image_view_by_id + #[derive(Debug, Clone)] + pub struct SystemImageViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SystemImageViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/images/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_view_by_id`] + /// + ///[`ClientSystemExt::ip_pool_view_by_id`]: super::ClientSystemExt::ip_pool_view_by_id + #[derive(Debug, Clone)] + pub struct IpPoolViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> IpPoolViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/ip-pools/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_view_by_id`] + /// + ///[`ClientSystemExt::silo_view_by_id`]: super::ClientSystemExt::silo_view_by_id + #[derive(Debug, Clone)] + pub struct SiloViewById<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> SiloViewById<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn send(self) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/by-id/silos/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view_by_id", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_list`] + /// + ///[`ClientSystemExt::certificate_list`]: super::ClientSystemExt::certificate_list + #[derive(Debug, Clone)] + pub struct CertificateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> CertificateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/certificates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::certificate_create`] + /// + ///[`ClientSystemExt::certificate_create`]: super::ClientSystemExt::certificate_create + #[derive(Debug, Clone)] + pub struct CertificateCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> CertificateCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `CertificateCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::CertificateCreate, + ) -> types::builder::CertificateCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/certificates` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::CertificateCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/certificates", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "certificate_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_view`] + /// + ///[`ClientSystemExt::certificate_view`]: super::ClientSystemExt::certificate_view + #[derive(Debug, Clone)] + pub struct CertificateView<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::certificate_delete`] + /// + ///[`ClientSystemExt::certificate_delete`]: super::ClientSystemExt::certificate_delete + #[derive(Debug, Clone)] + pub struct CertificateDelete<'a> { + client: &'a super::Client, + certificate: Result, + } + + impl<'a> CertificateDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + certificate: Err("certificate was not initialized".to_string()), + } + } + + pub fn certificate(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.certificate = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for certificate failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + certificate, + } = self; + let certificate = certificate.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/certificates/{}", + client.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::physical_disk_list`] + /// + ///[`ClientSystemExt::physical_disk_list`]: super::ClientSystemExt::physical_disk_list + #[derive(Debug, Clone)] + pub struct PhysicalDiskList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> PhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/disks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "physical_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::rack_list`] + /// + ///[`ClientSystemExt::rack_list`]: super::ClientSystemExt::rack_list + #[derive(Debug, Clone)] + pub struct RackList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> RackList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/racks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::rack_view`] + /// + ///[`ClientSystemExt::rack_view`]: super::ClientSystemExt::rack_view + #[derive(Debug, Clone)] + pub struct RackView<'a> { + client: &'a super::Client, + rack_id: Result<::uuid::Uuid, String>, + } + + impl<'a> RackView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + rack_id: Err("rack_id was not initialized".to_string()), + } + } + + pub fn rack_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.rack_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for rack_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let rack_id = rack_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::sled_list`] + /// + ///[`ClientSystemExt::sled_list`]: super::ClientSystemExt::sled_list + #[derive(Debug, Clone)] + pub struct SledList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/hardware/sleds", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::sled_view`] + /// + ///[`ClientSystemExt::sled_view`]: super::ClientSystemExt::sled_view + #[derive(Debug, Clone)] + pub struct SledView<'a> { + client: &'a super::Client, + sled_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SledView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + sled_id: Err("sled_id was not initialized".to_string()), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for sled_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::sled_physical_disk_list`] + /// + ///[`ClientSystemExt::sled_physical_disk_list`]: super::ClientSystemExt::sled_physical_disk_list + #[derive(Debug, Clone)] + pub struct SledPhysicalDiskList<'a> { + client: &'a super::Client, + sled_id: Result<::uuid::Uuid, String>, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SledPhysicalDiskList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + sled_id: Err("sled_id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn sled_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.sled_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for sled_id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + sled_id, + limit, + page_token, + sort_by, + } = self; + let sled_id = sled_id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/hardware/sleds/{}/disks", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_physical_disk_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/hardware/sleds/{sled_id}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::system_image_list`] + /// + ///[`ClientSystemExt::system_image_list`]: super::ClientSystemExt::system_image_list + #[derive(Debug, Clone)] + pub struct SystemImageList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemImageList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::system_image_create`] + /// + ///[`ClientSystemExt::system_image_create`]: super::ClientSystemExt::system_image_create + #[derive(Debug, Clone)] + pub struct SystemImageCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemImageCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `GlobalImageCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::GlobalImageCreate, + ) -> types::builder::GlobalImageCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::GlobalImageCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/images", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_image_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_image_view`] + /// + ///[`ClientSystemExt::system_image_view`]: super::ClientSystemExt::system_image_view + #[derive(Debug, Clone)] + pub struct SystemImageView<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_image_delete`] + /// + ///[`ClientSystemExt::system_image_delete`]: super::ClientSystemExt::system_image_delete + #[derive(Debug, Clone)] + pub struct SystemImageDelete<'a> { + client: &'a super::Client, + image_name: Result, + } + + impl<'a> SystemImageDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + image_name: Err("image_name was not initialized".to_string()), + } + } + + pub fn image_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.image_name = value + .try_into() + .map_err(|_| "conversion to `Name` for image_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let image_name = image_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_list`] + /// + ///[`ClientSystemExt::ip_pool_list`]: super::ClientSystemExt::ip_pool_list + #[derive(Debug, Clone)] + pub struct IpPoolList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> IpPoolList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_create`] + /// + ///[`ClientSystemExt::ip_pool_create`]: super::ClientSystemExt::ip_pool_create + #[derive(Debug, Clone)] + pub struct IpPoolCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `IpPoolCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolCreate) -> types::builder::IpPoolCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/ip-pools` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::IpPoolCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_view`] + /// + ///[`ClientSystemExt::ip_pool_view`]: super::ClientSystemExt::ip_pool_view + #[derive(Debug, Clone)] + pub struct IpPoolView<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_update`] + /// + ///[`ClientSystemExt::ip_pool_update`]: super::ClientSystemExt::ip_pool_update + #[derive(Debug, Clone)] + pub struct IpPoolUpdate<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `IpPoolUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolUpdate) -> types::builder::IpPoolUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::IpPoolUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_delete`] + /// + ///[`ClientSystemExt::ip_pool_delete`]: super::ClientSystemExt::ip_pool_delete + #[derive(Debug, Clone)] + pub struct IpPoolDelete<'a> { + client: &'a super::Client, + pool_name: Result, + } + + impl<'a> IpPoolDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, pool_name } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_list`] + /// + ///[`ClientSystemExt::ip_pool_range_list`]: super::ClientSystemExt::ip_pool_range_list + #[derive(Debug, Clone)] + pub struct IpPoolRangeList<'a> { + client: &'a super::Client, + pool_name: Result, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + pool_name, + limit, + page_token, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_range_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools/{pool_name}/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_add`] + /// + ///[`ClientSystemExt::ip_pool_range_add`]: super::ClientSystemExt::ip_pool_range_add + #[derive(Debug, Clone)] + pub struct IpPoolRangeAdd<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_add", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_range_remove`] + /// + ///[`ClientSystemExt::ip_pool_range_remove`]: super::ClientSystemExt::ip_pool_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolRangeRemove<'a> { + client: &'a super::Client, + pool_name: Result, + body: Result, + } + + impl<'a> IpPoolRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + pool_name: Err("pool_name was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn pool_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.pool_name = value + .try_into() + .map_err(|_| "conversion to `Name` for pool_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { + client, + pool_name, + body, + } = self; + let pool_name = pool_name.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + client.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_remove", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_view`] + /// + ///[`ClientSystemExt::ip_pool_service_view`]: super::ClientSystemExt::ip_pool_service_view + #[derive(Debug, Clone)] + pub struct IpPoolServiceView<'a> { + client: &'a super::Client, + } + + impl<'a> IpPoolServiceView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/ip-pools-service", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_list`] + /// + ///[`ClientSystemExt::ip_pool_service_range_list`]: super::ClientSystemExt::ip_pool_service_range_list + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> IpPoolServiceRangeList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/ip-pools-service/ranges` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_add`] + /// + ///[`ClientSystemExt::ip_pool_service_range_add`]: super::ClientSystemExt::ip_pool_service_range_add + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeAdd<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeAdd<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/add", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_add", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::ip_pool_service_range_remove`] + /// + ///[`ClientSystemExt::ip_pool_service_range_remove`]: super::ClientSystemExt::ip_pool_service_range_remove + #[derive(Debug, Clone)] + pub struct IpPoolServiceRangeRemove<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> IpPoolServiceRangeRemove<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `IpRange` for body failed".to_string()); + self + } + + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/ip-pools-service/ranges/remove", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_remove", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_metric`] + /// + ///[`ClientSystemExt::system_metric`]: super::ClientSystemExt::system_metric + #[derive(Debug, Clone)] + pub struct SystemMetric<'a> { + client: &'a super::Client, + metric_name: Result, + end_time: Result>, String>, + id: Result<::uuid::Uuid, String>, + limit: Result, String>, + page_token: Result, String>, + start_time: Result>, String>, + } + + impl<'a> SystemMetric<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + metric_name: Err("metric_name was not initialized".to_string()), + end_time: Ok(None), + id: Err("id was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + start_time: Ok(None), + } + } + + pub fn metric_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.metric_name = value + .try_into() + .map_err(|_| "conversion to `SystemMetricName` for metric_name failed".to_string()); + self + } + + pub fn end_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.end_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for end_time \ + failed" + .to_string() + }); + self + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn start_time(mut self, value: V) -> Self + where + V: std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>, + { + self.start_time = value.try_into().map(Some).map_err(|_| { + "conversion to `:: chrono :: DateTime < :: chrono :: offset :: Utc >` for \ + start_time failed" + .to_string() + }); + self + } + + ///Sends a `GET` request to `/system/metrics/{metric_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + metric_name, + end_time, + id, + limit, + page_token, + start_time, + } = self; + let metric_name = metric_name.map_err(Error::InvalidRequest)?; + let end_time = end_time.map_err(Error::InvalidRequest)?; + let id = id.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let start_time = start_time.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/metrics/{}", + client.baseurl, + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_metric", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientPolicyExt::system_policy_view`] + /// + ///[`ClientPolicyExt::system_policy_view`]: super::ClientPolicyExt::system_policy_view + #[derive(Debug, Clone)] + pub struct SystemPolicyView<'a> { + client: &'a super::Client, + } + + impl<'a> SystemPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/system/policy", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientPolicyExt::system_policy_update`] + /// + ///[`ClientPolicyExt::system_policy_update`]: super::ClientPolicyExt::system_policy_update + #[derive(Debug, Clone)] + pub struct SystemPolicyUpdate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `FleetRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FleetRolePolicy) -> types::builder::FleetRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::FleetRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/policy", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saga_list`] + /// + ///[`ClientSystemExt::saga_list`]: super::ClientSystemExt::saga_list + #[derive(Debug, Clone)] + pub struct SagaList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SagaList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/sagas", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::saga_view`] + /// + ///[`ClientSystemExt::saga_view`]: super::ClientSystemExt::saga_view + #[derive(Debug, Clone)] + pub struct SagaView<'a> { + client: &'a super::Client, + saga_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SagaView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + saga_id: Err("saga_id was not initialized".to_string()), + } + } + + pub fn saga_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.saga_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for saga_id failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let saga_id = saga_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_list`] + /// + ///[`ClientSystemExt::silo_list`]: super::ClientSystemExt::silo_list + #[derive(Debug, Clone)] + pub struct SiloList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/silos", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/silos` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::silo_create`] + /// + ///[`ClientSystemExt::silo_create`]: super::ClientSystemExt::silo_create + #[derive(Debug, Clone)] + pub struct SiloCreate<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SiloCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloCreate) -> types::builder::SiloCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/system/silos` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SiloCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/system/silos", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_view`] + /// + ///[`ClientSystemExt::silo_view`]: super::ClientSystemExt::silo_view + #[derive(Debug, Clone)] + pub struct SiloView<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_delete`] + /// + ///[`ClientSystemExt::silo_delete`]: super::ClientSystemExt::silo_delete + #[derive(Debug, Clone)] + pub struct SiloDelete<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_identity_provider_list`] + /// + ///[`ClientSystemExt::silo_identity_provider_list`]: super::ClientSystemExt::silo_identity_provider_list + #[derive(Debug, Clone)] + pub struct SiloIdentityProviderList<'a> { + client: &'a super::Client, + silo_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloIdentityProviderList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + silo_name, + limit, + page_token, + sort_by, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_identity_provider_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::local_idp_user_create`] + /// + ///[`ClientSystemExt::local_idp_user_create`]: super::ClientSystemExt::local_idp_user_create + #[derive(Debug, Clone)] + pub struct LocalIdpUserCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> LocalIdpUserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `UserCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::local_idp_user_delete`] + /// + ///[`ClientSystemExt::local_idp_user_delete`]: super::ClientSystemExt::local_idp_user_delete + #[derive(Debug, Clone)] + pub struct LocalIdpUserDelete<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + } + + impl<'a> LocalIdpUserDelete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "local_idp_user_delete", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::local_idp_user_set_password`] + /// + ///[`ClientSystemExt::local_idp_user_set_password`]: super::ClientSystemExt::local_idp_user_set_password + #[derive(Debug, Clone)] + pub struct LocalIdpUserSetPassword<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + body: Result, + } + + impl<'a> LocalIdpUserSetPassword<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + body: Err("body was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `UserPassword` for body failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_set_password", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saml_identity_provider_create`] + /// + ///[`ClientSystemExt::saml_identity_provider_create`]: super::ClientSystemExt::saml_identity_provider_create + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderCreate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SamlIdentityProviderCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `SamlIdentityProviderCreate` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SamlIdentityProviderCreate, + ) -> types::builder::SamlIdentityProviderCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| { + types::SamlIdentityProviderCreate::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "saml_identity_provider_create", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::saml_identity_provider_view`] + /// + ///[`ClientSystemExt::saml_identity_provider_view`]: super::ClientSystemExt::saml_identity_provider_view + #[derive(Debug, Clone)] + pub struct SamlIdentityProviderView<'a> { + client: &'a super::Client, + silo_name: Result, + provider_name: Result, + } + + impl<'a> SamlIdentityProviderView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + provider_name: Err("provider_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn provider_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.provider_name = value + .try_into() + .map_err(|_| "conversion to `Name` for provider_name failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + provider_name, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let provider_name = provider_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/identity-providers/saml/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saml_identity_provider_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_policy_view`] + /// + ///[`ClientSystemExt::silo_policy_view`]: super::ClientSystemExt::silo_policy_view + #[derive(Debug, Clone)] + pub struct SiloPolicyView<'a> { + client: &'a super::Client, + silo_name: Result, + } + + impl<'a> SiloPolicyView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, silo_name } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_policy_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_policy_update`] + /// + ///[`ClientSystemExt::silo_policy_update`]: super::ClientSystemExt::silo_policy_update + #[derive(Debug, Clone)] + pub struct SiloPolicyUpdate<'a> { + client: &'a super::Client, + silo_name: Result, + body: Result, + } + + impl<'a> SiloPolicyUpdate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SiloRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::SiloRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_policy_update", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::silo_users_list`] + /// + ///[`ClientSystemExt::silo_users_list`]: super::ClientSystemExt::silo_users_list + #[derive(Debug, Clone)] + pub struct SiloUsersList<'a> { + client: &'a super::Client, + silo_name: Result, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SiloUsersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + limit, + page_token, + sort_by, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/users/all", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_users_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/silos/{silo_name}/users/all` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::silo_user_view`] + /// + ///[`ClientSystemExt::silo_user_view`]: super::ClientSystemExt::silo_user_view + #[derive(Debug, Clone)] + pub struct SiloUserView<'a> { + client: &'a super::Client, + silo_name: Result, + user_id: Result<::uuid::Uuid, String>, + } + + impl<'a> SiloUserView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + silo_name: Err("silo_name was not initialized".to_string()), + user_id: Err("user_id was not initialized".to_string()), + } + } + + pub fn silo_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.silo_name = value + .try_into() + .map_err(|_| "conversion to `Name` for silo_name failed".to_string()); + self + } + + pub fn user_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.user_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for user_id failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/users/id/{user_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + silo_name, + user_id, + } = self; + let silo_name = silo_name.map_err(Error::InvalidRequest)?; + let user_id = user_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/silos/{}/users/id/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_user_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_user_list`] + /// + ///[`ClientSystemExt::system_user_list`]: super::ClientSystemExt::system_user_list + #[derive(Debug, Clone)] + pub struct SystemUserList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUserList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/user` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/system/user", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/system/user` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::system_user_view`] + /// + ///[`ClientSystemExt::system_user_view`]: super::ClientSystemExt::system_user_view + #[derive(Debug, Clone)] + pub struct SystemUserView<'a> { + client: &'a super::Client, + user_name: Result, + } + + impl<'a> SystemUserView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + user_name: Err("user_name was not initialized".to_string()), + } + } + + pub fn user_name(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.user_name = value + .try_into() + .map_err(|_| "conversion to `Name` for user_name failed".to_string()); + self + } + + ///Sends a `GET` request to `/system/user/{user_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, user_name } = self; + let user_name = user_name.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/system/user/{}", + client.baseurl, + encode_path(&user_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientMetricsExt::timeseries_schema_get`] + /// + ///[`ClientMetricsExt::timeseries_schema_get`]: super::ClientMetricsExt::timeseries_schema_get + #[derive(Debug, Clone)] + pub struct TimeseriesSchemaGet<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> TimeseriesSchemaGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/timeseries/schema` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/timeseries/schema", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "timeseries_schema_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/timeseries/schema` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSilosExt::user_list`] + /// + ///[`ClientSilosExt::user_list`]: super::ClientSilosExt::user_list + #[derive(Debug, Clone)] + pub struct UserList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UserList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/users", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "user_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/users` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientDisksExt::disk_list_v1`] + /// + ///[`ClientDisksExt::disk_list_v1`]: super::ClientDisksExt::disk_list_v1 + #[derive(Debug, Clone)] + pub struct DiskListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> DiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientDisksExt::disk_create_v1`] + /// + ///[`ClientDisksExt::disk_create_v1`]: super::ClientDisksExt::disk_create_v1 + #[derive(Debug, Clone)] + pub struct DiskCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> DiskCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/disks` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/disks", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_view_v1`] + /// + ///[`ClientDisksExt::disk_view_v1`]: super::ClientDisksExt::disk_view_v1 + #[derive(Debug, Clone)] + pub struct DiskViewV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientDisksExt::disk_delete_v1`] + /// + ///[`ClientDisksExt::disk_delete_v1`]: super::ClientDisksExt::disk_delete_v1 + #[derive(Debug, Clone)] + pub struct DiskDeleteV1<'a> { + client: &'a super::Client, + disk: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> DiskDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + disk: Err("disk was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn disk(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.disk = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for disk failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + disk, + organization, + project, + } = self; + let disk = disk.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/disks/{}", + client.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_list_v1`] + /// + ///[`ClientInstancesExt::instance_list_v1`]: super::ClientInstancesExt::instance_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientInstancesExt::instance_create_v1`] + /// + ///[`ClientInstancesExt::instance_create_v1`]: super::ClientInstancesExt::instance_create_v1 + #[derive(Debug, Clone)] + pub struct InstanceCreateV1<'a> { + client: &'a super::Client, + organization: Result, String>, + project: Result, + body: Result, + } + + impl<'a> InstanceCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Ok(None), + project: Err("project was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + project, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/instances", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_view_v1`] + /// + ///[`ClientInstancesExt::instance_view_v1`]: super::ClientInstancesExt::instance_view_v1 + #[derive(Debug, Clone)] + pub struct InstanceViewV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_delete_v1`] + /// + ///[`ClientInstancesExt::instance_delete_v1`]: super::ClientInstancesExt::instance_delete_v1 + #[derive(Debug, Clone)] + pub struct InstanceDeleteV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_list_v1`] + /// + ///[`ClientInstancesExt::instance_disk_list_v1`]: super::ClientInstancesExt::instance_disk_list_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskListV1<'a> { + client: &'a super::Client, + instance: Result, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + project: Result, String>, + sort_by: Result, String>, + } + + impl<'a> InstanceDiskListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + limit, + organization, + page_token, + project, + sort_by, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/instances/{instance}/disks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + project: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_attach_v1`] + /// + ///[`ClientInstancesExt::instance_disk_attach_v1`]: super::ClientInstancesExt::instance_disk_attach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskAttachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskAttachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskPath::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/attach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_disk_detach_v1`] + /// + ///[`ClientInstancesExt::instance_disk_detach_v1`]: super::ClientInstancesExt::instance_disk_detach_v1 + #[derive(Debug, Clone)] + pub struct InstanceDiskDetachV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceDiskDetachV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `DiskPath` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::DiskPath::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/disks/detach", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_migrate_v1`] + /// + ///[`ClientInstancesExt::instance_migrate_v1`]: super::ClientInstancesExt::instance_migrate_v1 + #[derive(Debug, Clone)] + pub struct InstanceMigrateV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + body: Result, + } + + impl<'a> InstanceMigrateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `InstanceMigrate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + body, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::InstanceMigrate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/migrate", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_reboot_v1`] + /// + ///[`ClientInstancesExt::instance_reboot_v1`]: super::ClientInstancesExt::instance_reboot_v1 + #[derive(Debug, Clone)] + pub struct InstanceRebootV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceRebootV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/reboot", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console_v1`] + /// + ///[`ClientInstancesExt::instance_serial_console_v1`]: super::ClientInstancesExt::instance_serial_console_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleV1<'a> { + client: &'a super::Client, + instance: Result, + from_start: Result, String>, + max_bytes: Result, String>, + most_recent: Result, String>, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + from_start: Ok(None), + max_bytes: Ok(None), + most_recent: Ok(None), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn from_start(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.from_start = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for from_start failed".to_string()); + self + } + + pub fn max_bytes(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.max_bytes = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for max_bytes failed".to_string()); + self + } + + pub fn most_recent(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.most_recent = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `u64` for most_recent failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + from_start, + max_bytes, + most_recent, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let from_start = from_start.map_err(Error::InvalidRequest)?; + let max_bytes = max_bytes.map_err(Error::InvalidRequest)?; + let most_recent = most_recent.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_serial_console_stream_v1`] + /// + ///[`ClientInstancesExt::instance_serial_console_stream_v1`]: super::ClientInstancesExt::instance_serial_console_stream_v1 + #[derive(Debug, Clone)] + pub struct InstanceSerialConsoleStreamV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceSerialConsoleStreamV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + client.baseurl, + encode_path(&instance.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`ClientInstancesExt::instance_start_v1`] + /// + ///[`ClientInstancesExt::instance_start_v1`]: super::ClientInstancesExt::instance_start_v1 + #[derive(Debug, Clone)] + pub struct InstanceStartV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStartV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/start", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientInstancesExt::instance_stop_v1`] + /// + ///[`ClientInstancesExt::instance_stop_v1`]: super::ClientInstancesExt::instance_stop_v1 + #[derive(Debug, Clone)] + pub struct InstanceStopV1<'a> { + client: &'a super::Client, + instance: Result, + organization: Result, String>, + project: Result, String>, + } + + impl<'a> InstanceStopV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + instance: Err("instance was not initialized".to_string()), + organization: Ok(None), + project: Ok(None), + } + } + + pub fn instance(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.instance = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for instance failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn send(self) -> Result, Error> { + let Self { + client, + instance, + organization, + project, + } = self; + let instance = instance.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let project = project.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/instances/{}/stop", + client.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_list_v1`] + /// + ///[`ClientOrganizationsExt::organization_list_v1`]: super::ClientOrganizationsExt::organization_list_v1 + #[derive(Debug, Clone)] + pub struct OrganizationListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> OrganizationListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/organizations` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientOrganizationsExt::organization_create_v1`] + /// + ///[`ClientOrganizationsExt::organization_create_v1`]: super::ClientOrganizationsExt::organization_create_v1 + #[derive(Debug, Clone)] + pub struct OrganizationCreateV1<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> OrganizationCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::OrganizationCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/organizations", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_view_v1`] + /// + ///[`ClientOrganizationsExt::organization_view_v1`]: super::ClientOrganizationsExt::organization_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_update_v1`] + /// + ///[`ClientOrganizationsExt::organization_update_v1`]: super::ClientOrganizationsExt::organization_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `OrganizationUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_delete_v1`] + /// + ///[`ClientOrganizationsExt::organization_delete_v1`]: super::ClientOrganizationsExt::organization_delete_v1 + #[derive(Debug, Clone)] + pub struct OrganizationDeleteV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_view_v1`] + /// + ///[`ClientOrganizationsExt::organization_policy_view_v1`]: super::ClientOrganizationsExt::organization_policy_view_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyViewV1<'a> { + client: &'a super::Client, + organization: Result, + } + + impl<'a> OrganizationPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organization_policy_update_v1`] + /// + ///[`ClientOrganizationsExt::organization_policy_update_v1`]: super::ClientOrganizationsExt::organization_policy_update_v1 + #[derive(Debug, Clone)] + pub struct OrganizationPolicyUpdateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> OrganizationPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `OrganizationRolePolicy` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::OrganizationRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/organizations/{}/policy", + client.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_list_v1`] + /// + ///[`ClientProjectsExt::project_list_v1`]: super::ClientProjectsExt::project_list_v1 + #[derive(Debug, Clone)] + pub struct ProjectListV1<'a> { + client: &'a super::Client, + limit: Result, String>, + organization: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> ProjectListV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrIdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + organization, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/projects` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + organization: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientProjectsExt::project_create_v1`] + /// + ///[`ClientProjectsExt::project_create_v1`]: super::ClientProjectsExt::project_create_v1 + #[derive(Debug, Clone)] + pub struct ProjectCreateV1<'a> { + client: &'a super::Client, + organization: Result, + body: Result, + } + + impl<'a> ProjectCreateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + organization: Err("organization was not initialized".to_string()), + body: Ok(::std::default::Default::default()), + } + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectCreate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/projects` + pub async fn send(self) -> Result, Error> { + let Self { + client, + organization, + body, + } = self; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectCreate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/projects", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_view_v1`] + /// + ///[`ClientProjectsExt::project_view_v1`]: super::ClientProjectsExt::project_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_update_v1`] + /// + ///[`ClientProjectsExt::project_update_v1`]: super::ClientProjectsExt::project_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectUpdate` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectUpdate::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_delete_v1`] + /// + ///[`ClientProjectsExt::project_delete_v1`]: super::ClientProjectsExt::project_delete_v1 + #[derive(Debug, Clone)] + pub struct ProjectDeleteV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectDeleteV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_view_v1`] + /// + ///[`ClientProjectsExt::project_policy_view_v1`]: super::ClientProjectsExt::project_policy_view_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyViewV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + } + + impl<'a> ProjectPolicyViewV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientProjectsExt::project_policy_update_v1`] + /// + ///[`ClientProjectsExt::project_policy_update_v1`]: super::ClientProjectsExt::project_policy_update_v1 + #[derive(Debug, Clone)] + pub struct ProjectPolicyUpdateV1<'a> { + client: &'a super::Client, + project: Result, + organization: Result, String>, + body: Result, + } + + impl<'a> ProjectPolicyUpdateV1<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + project: Err("project was not initialized".to_string()), + organization: Ok(None), + body: Ok(::std::default::Default::default()), + } + } + + pub fn project(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.project = value + .try_into() + .map_err(|_| "conversion to `NameOrId` for project failed".to_string()); + self + } + + pub fn organization(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.organization = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `NameOrId` for organization failed".to_string()); + self + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `ProjectRolePolicy` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + project, + organization, + body, + } = self; + let project = project.map_err(Error::InvalidRequest)?; + let organization = organization.map_err(Error::InvalidRequest)?; + let body = body + .and_then(|v| types::ProjectRolePolicy::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/projects/{}/policy", + client.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update_v1", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_component_version_list`] + /// + ///[`ClientSystemExt::system_component_version_list`]: super::ClientSystemExt::system_component_version_list + #[derive(Debug, Clone)] + pub struct SystemComponentVersionList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemComponentVersionList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/components` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/components", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_component_version_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/components` + pub fn stream( + self, + ) -> impl futures::Stream>> + + Unpin + + 'a { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::update_deployments_list`] + /// + ///[`ClientSystemExt::update_deployments_list`]: super::ClientSystemExt::update_deployments_list + #[derive(Debug, Clone)] + pub struct UpdateDeploymentsList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> UpdateDeploymentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/deployments", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployments_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/deployments` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::update_deployment_view`] + /// + ///[`ClientSystemExt::update_deployment_view`]: super::ClientSystemExt::update_deployment_view + #[derive(Debug, Clone)] + pub struct UpdateDeploymentView<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + } + + impl<'a> UpdateDeploymentView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, id } = self; + let id = id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/deployments/{}", + client.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployment_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_refresh`] + /// + ///[`ClientSystemExt::system_update_refresh`]: super::ClientSystemExt::system_update_refresh + #[derive(Debug, Clone)] + pub struct SystemUpdateRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/refresh", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_refresh", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_start`] + /// + ///[`ClientSystemExt::system_update_start`]: super::ClientSystemExt::system_update_start + #[derive(Debug, Clone)] + pub struct SystemUpdateStart<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemUpdateStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `SystemUpdateStart` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SystemUpdateStart, + ) -> types::builder::SystemUpdateStart, + { + self.body = self.body.map(f); + self + } + + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::SystemUpdateStart::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/start", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_update_start", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_stop`] + /// + ///[`ClientSystemExt::system_update_stop`]: super::ClientSystemExt::system_update_stop + #[derive(Debug, Clone)] + pub struct SystemUpdateStop<'a> { + client: &'a super::Client, + } + + impl<'a> SystemUpdateStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/stop", client.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_stop", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_list`] + /// + ///[`ClientSystemExt::system_update_list`]: super::ClientSystemExt::system_update_list + #[derive(Debug, Clone)] + pub struct SystemUpdateList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + sort_by: Result, String>, + } + + impl<'a> SystemUpdateList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + sort_by: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::num::NonZeroU32>, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.page_token = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for page_token failed".to_string() + }); + self + } + + pub fn sort_by(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.sort_by = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `IdSortMode` for sort_by failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let sort_by = sort_by.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/update/updates", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Streams `GET` requests to `/v1/system/update/updates` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use ::futures::StreamExt; + use ::futures::TryFutureExt; + use ::futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + sort_by: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + } + + ///Builder for [`ClientSystemExt::system_update_view`] + /// + ///[`ClientSystemExt::system_update_view`]: super::ClientSystemExt::system_update_view + #[derive(Debug, Clone)] + pub struct SystemUpdateView<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateView<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn send(self) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_view", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_update_components_list`] + /// + ///[`ClientSystemExt::system_update_components_list`]: super::ClientSystemExt::system_update_components_list + #[derive(Debug, Clone)] + pub struct SystemUpdateComponentsList<'a> { + client: &'a super::Client, + version: Result, + } + + impl<'a> SystemUpdateComponentsList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + version: Err("version was not initialized".to_string()), + } + } + + pub fn version(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.version = value + .try_into() + .map_err(|_| "conversion to `SemverVersion` for version failed".to_string()); + self + } + + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, version } = self; + let version = version.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/v1/system/update/updates/{}/components", + client.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_components_list", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSystemExt::system_version`] + /// + ///[`ClientSystemExt::system_version`]: super::ClientSystemExt::system_version + #[derive(Debug, Clone)] + pub struct SystemVersion<'a> { + client: &'a super::Client, + } + + impl<'a> SystemVersion<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/v1/system/update/version", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_version", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; + pub use super::ClientDisksExt; + pub use super::ClientHiddenExt; + pub use super::ClientImagesExt; + pub use super::ClientInstancesExt; + pub use super::ClientLoginExt; + pub use super::ClientMetricsExt; + pub use super::ClientOrganizationsExt; + pub use super::ClientPolicyExt; + pub use super::ClientProjectsExt; + pub use super::ClientRolesExt; + pub use super::ClientSessionExt; + pub use super::ClientSilosExt; + pub use super::ClientSnapshotsExt; + pub use super::ClientSystemExt; + pub use super::ClientVpcsExt; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/nexus_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/nexus_positional.rs new file mode 100644 index 00000000..12cfaa1e --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/nexus_positional.rs @@ -0,0 +1,25022 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///Describes properties that should uniquely identify a Gimlet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes properties that should uniquely identify a + /// Gimlet.", + /// "type": "object", + /// "required": [ + /// "part", + /// "revision", + /// "serial" + /// ], + /// "properties": { + /// "part": { + /// "type": "string" + /// }, + /// "revision": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "serial": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Baseboard { + pub part: ::std::string::String, + pub revision: i64, + pub serial: ::std::string::String, + } + + impl ::std::convert::From<&Baseboard> for Baseboard { + fn from(value: &Baseboard) -> Self { + value.clone() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "number", + /// "format": "double" + /// }, + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum BinRangedouble { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: f64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: f64, start: f64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: f64 }, + } + + impl ::std::convert::From<&Self> for BinRangedouble { + fn from(value: &BinRangedouble) -> Self { + value.clone() + } + } + + ///A type storing a range over `T`. + /// + ///This type supports ranges similar to the `RangeTo`, `Range` and + /// `RangeFrom` types in the standard library. Those cover `(..end)`, + /// `(start..end)`, and `(start..)` respectively. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A type storing a range over `T`.\n\nThis type supports + /// ranges similar to the `RangeTo`, `Range` and `RangeFrom` types in the + /// standard library. Those cover `(..end)`, `(start..end)`, and `(start..)` + /// respectively.", + /// "oneOf": [ + /// { + /// "description": "A range unbounded below and exclusively above, + /// `..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_to" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and exclusively + /// above, `start..end`.", + /// "type": "object", + /// "required": [ + /// "end", + /// "start", + /// "type" + /// ], + /// "properties": { + /// "end": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "A range bounded inclusively below and unbounded + /// above, `start..`.", + /// "type": "object", + /// "required": [ + /// "start", + /// "type" + /// ], + /// "properties": { + /// "start": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "range_from" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum BinRangeint64 { + ///A range unbounded below and exclusively above, `..end`. + #[serde(rename = "range_to")] + RangeTo { end: i64 }, + ///A range bounded inclusively below and exclusively above, + /// `start..end`. + #[serde(rename = "range")] + Range { end: i64, start: i64 }, + ///A range bounded inclusively below and unbounded above, `start..`. + #[serde(rename = "range_from")] + RangeFrom { start: i64 }, + } + + impl ::std::convert::From<&Self> for BinRangeint64 { + fn from(value: &BinRangeint64) -> Self { + value.clone() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangedouble" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Bindouble { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangedouble, + } + + impl ::std::convert::From<&Bindouble> for Bindouble { + fn from(value: &Bindouble) -> Self { + value.clone() + } + } + + ///Type storing bin edges and a count of samples within it. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Type storing bin edges and a count of samples within + /// it.", + /// "type": "object", + /// "required": [ + /// "count", + /// "range" + /// ], + /// "properties": { + /// "count": { + /// "description": "The total count of samples in this bin.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "range": { + /// "description": "The range of the support covered by this bin.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BinRangeint64" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Binint64 { + ///The total count of samples in this bin. + pub count: u64, + ///The range of the support covered by this bin. + pub range: BinRangeint64, + } + + impl ::std::convert::From<&Binint64> for Binint64 { + fn from(value: &Binint64) -> Self { + value.clone() + } + } + + ///`BlockSize` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "disk block size in bytes", + /// "type": "integer", + /// "enum": [ + /// 512, + /// 2048, + /// 4096 + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct BlockSize(i64); + impl ::std::ops::Deref for BlockSize { + type Target = i64; + fn deref(&self) -> &i64 { + &self.0 + } + } + + impl ::std::convert::From for i64 { + fn from(value: BlockSize) -> Self { + value.0 + } + } + + impl ::std::convert::From<&BlockSize> for BlockSize { + fn from(value: &BlockSize) -> Self { + value.clone() + } + } + + impl ::std::convert::TryFrom for BlockSize { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> ::std::result::Result { + if ![512_i64, 2048_i64, 4096_i64].contains(&value) { + Err("invalid value".into()) + } else { + Ok(Self(value)) + } + } + } + + impl<'de> ::serde::Deserialize<'de> for BlockSize { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + Self::try_from(::deserialize(deserializer)?) + .map_err(|e| ::custom(e.to_string())) + } + } + + ///A count of bytes, typically used either for memory or storage capacity + /// + ///The maximum supported byte count is [`i64::MAX`]. This makes it + /// somewhat inconvenient to define constructors: a u32 constructor can be + /// infallible, but an i64 constructor can fail (if the value is negative) + /// and a u64 constructor can fail (if the value is larger than i64::MAX). + /// We provide all of these for consumers' convenience. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A count of bytes, typically used either for memory or + /// storage capacity\n\nThe maximum supported byte count is [`i64::MAX`]. + /// This makes it somewhat inconvenient to define constructors: a u32 + /// constructor can be infallible, but an i64 constructor can fail (if the + /// value is negative) and a u64 constructor can fail (if the value is + /// larger than i64::MAX). We provide all of these for consumers' + /// convenience.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct ByteCount(pub u64); + impl ::std::ops::Deref for ByteCount { + type Target = u64; + fn deref(&self) -> &u64 { + &self.0 + } + } + + impl ::std::convert::From for u64 { + fn from(value: ByteCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&ByteCount> for ByteCount { + fn from(value: &ByteCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for ByteCount { + fn from(value: u64) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for ByteCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for ByteCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for ByteCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for ByteCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for ByteCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of a [`Certificate`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Certificate`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "service", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "service": { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Certificate { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub service: ServiceUsingCertificate, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Certificate> for Certificate { + fn from(value: &Certificate) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Certificate`](crate::external_api::views::Certificate)", + /// "type": "object", + /// "required": [ + /// "cert", + /// "description", + /// "key", + /// "name", + /// "service" + /// ], + /// "properties": { + /// "cert": { + /// "description": "PEM file containing public certificate chain", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "key": { + /// "description": "PEM file containing private key", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "service": { + /// "description": "The service using this certificate", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ServiceUsingCertificate" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CertificateCreate { + ///PEM file containing public certificate chain + pub cert: ::std::vec::Vec, + pub description: ::std::string::String, + ///PEM file containing private key + pub key: ::std::vec::Vec, + pub name: Name, + ///The service using this certificate + pub service: ServiceUsingCertificate, + } + + impl ::std::convert::From<&CertificateCreate> for CertificateCreate { + fn from(value: &CertificateCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Certificate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CertificateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&CertificateResultsPage> for CertificateResultsPage { + fn from(value: &CertificateResultsPage) -> Self { + value.clone() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ComponentUpdate { + pub component_type: UpdateableComponentType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&ComponentUpdate> for ComponentUpdate { + fn from(value: &ComponentUpdate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ComponentUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ComponentUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ComponentUpdateResultsPage> for ComponentUpdateResultsPage { + fn from(value: &ComponentUpdateResultsPage) -> Self { + value.clone() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "number", + /// "format": "double" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Cumulativedouble { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: f64, + } + + impl ::std::convert::From<&Cumulativedouble> for Cumulativedouble { + fn from(value: &Cumulativedouble) -> Self { + value.clone() + } + } + + ///A cumulative or counter data type. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A cumulative or counter data type.", + /// "type": "object", + /// "required": [ + /// "start_time", + /// "value" + /// ], + /// "properties": { + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "value": { + /// "type": "integer", + /// "format": "int64" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Cumulativeint64 { + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + pub value: i64, + } + + impl ::std::convert::From<&Cumulativeint64> for Cumulativeint64 { + fn from(value: &Cumulativeint64) -> Self { + value.clone() + } + } + + ///A `Datum` is a single sampled data point from a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Datum` is a single sampled data point from a + /// metric.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "boolean" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bool" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "integer", + /// "format": "int64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "number", + /// "format": "double" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "string" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "bytes" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativeint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Cumulativedouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "cumulative_f64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramint64" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_i64" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "datum", + /// "type" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Histogramdouble" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "histogram_f64" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "datum")] + pub enum Datum { + #[serde(rename = "bool")] + Bool(bool), + #[serde(rename = "i64")] + I64(i64), + #[serde(rename = "f64")] + F64(f64), + #[serde(rename = "string")] + String(::std::string::String), + #[serde(rename = "bytes")] + Bytes(::std::vec::Vec), + #[serde(rename = "cumulative_i64")] + CumulativeI64(Cumulativeint64), + #[serde(rename = "cumulative_f64")] + CumulativeF64(Cumulativedouble), + #[serde(rename = "histogram_i64")] + HistogramI64(Histogramint64), + #[serde(rename = "histogram_f64")] + HistogramF64(Histogramdouble), + } + + impl ::std::convert::From<&Self> for Datum { + fn from(value: &Datum) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Datum { + fn from(value: bool) -> Self { + Self::Bool(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: i64) -> Self { + Self::I64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: f64) -> Self { + Self::F64(value) + } + } + + impl ::std::convert::From<::std::vec::Vec> for Datum { + fn from(value: ::std::vec::Vec) -> Self { + Self::Bytes(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativeint64) -> Self { + Self::CumulativeI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Cumulativedouble) -> Self { + Self::CumulativeF64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramint64) -> Self { + Self::HistogramI64(value) + } + } + + impl ::std::convert::From for Datum { + fn from(value: Histogramdouble) -> Self { + Self::HistogramF64(value) + } + } + + ///The type of an individual datum of a metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The type of an individual datum of a metric.", + /// "type": "string", + /// "enum": [ + /// "bool", + /// "i64", + /// "f64", + /// "string", + /// "bytes", + /// "cumulative_i64", + /// "cumulative_f64", + /// "histogram_i64", + /// "histogram_f64" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum DatumType { + #[serde(rename = "bool")] + Bool, + #[serde(rename = "i64")] + I64, + #[serde(rename = "f64")] + F64, + #[serde(rename = "string")] + String, + #[serde(rename = "bytes")] + Bytes, + #[serde(rename = "cumulative_i64")] + CumulativeI64, + #[serde(rename = "cumulative_f64")] + CumulativeF64, + #[serde(rename = "histogram_i64")] + HistogramI64, + #[serde(rename = "histogram_f64")] + HistogramF64, + } + + impl ::std::convert::From<&Self> for DatumType { + fn from(value: &DatumType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DatumType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Bool => f.write_str("bool"), + Self::I64 => f.write_str("i64"), + Self::F64 => f.write_str("f64"), + Self::String => f.write_str("string"), + Self::Bytes => f.write_str("bytes"), + Self::CumulativeI64 => f.write_str("cumulative_i64"), + Self::CumulativeF64 => f.write_str("cumulative_f64"), + Self::HistogramI64 => f.write_str("histogram_i64"), + Self::HistogramF64 => f.write_str("histogram_f64"), + } + } + } + + impl ::std::str::FromStr for DatumType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bool" => Ok(Self::Bool), + "i64" => Ok(Self::I64), + "f64" => Ok(Self::F64), + "string" => Ok(Self::String), + "bytes" => Ok(Self::Bytes), + "cumulative_i64" => Ok(Self::CumulativeI64), + "cumulative_f64" => Ok(Self::CumulativeF64), + "histogram_i64" => Ok(Self::HistogramI64), + "histogram_f64" => Ok(Self::HistogramF64), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DatumType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DatumType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DerEncodedKeyPair` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "private_key", + /// "public_cert" + /// ], + /// "properties": { + /// "private_key": { + /// "description": "request signing private key (base64 encoded der + /// file)", + /// "type": "string" + /// }, + /// "public_cert": { + /// "description": "request signing public certificate (base64 encoded + /// der file)", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DerEncodedKeyPair { + ///request signing private key (base64 encoded der file) + pub private_key: ::std::string::String, + ///request signing public certificate (base64 encoded der file) + pub public_cert: ::std::string::String, + } + + impl ::std::convert::From<&DerEncodedKeyPair> for DerEncodedKeyPair { + fn from(value: &DerEncodedKeyPair) -> Self { + value.clone() + } + } + + ///`DeviceAccessTokenRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id", + /// "device_code", + /// "grant_type" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "device_code": { + /// "type": "string" + /// }, + /// "grant_type": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAccessTokenRequest { + pub client_id: ::uuid::Uuid, + pub device_code: ::std::string::String, + pub grant_type: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAccessTokenRequest> for DeviceAccessTokenRequest { + fn from(value: &DeviceAccessTokenRequest) -> Self { + value.clone() + } + } + + ///`DeviceAuthRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "client_id" + /// ], + /// "properties": { + /// "client_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAuthRequest { + pub client_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&DeviceAuthRequest> for DeviceAuthRequest { + fn from(value: &DeviceAuthRequest) -> Self { + value.clone() + } + } + + ///`DeviceAuthVerify` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "user_code" + /// ], + /// "properties": { + /// "user_code": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DeviceAuthVerify { + pub user_code: ::std::string::String, + } + + impl ::std::convert::From<&DeviceAuthVerify> for DeviceAuthVerify { + fn from(value: &DeviceAuthVerify) -> Self { + value.clone() + } + } + + ///`Digest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "sha256" + /// ] + /// }, + /// "value": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum Digest { + #[serde(rename = "sha256")] + Sha256(::std::string::String), + } + + impl ::std::convert::From<&Self> for Digest { + fn from(value: &Digest) -> Self { + value.clone() + } + } + + ///Client view of a [`Disk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Disk`]", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "device_path", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "device_path": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "snapshot_id": { + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Disk { + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub device_path: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub image_id: ::std::option::Option<::uuid::Uuid>, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub snapshot_id: ::std::option::Option<::uuid::Uuid>, + pub state: DiskState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Disk> for Disk { + fn from(value: &Disk) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskCreate { + pub description: ::std::string::String, + ///initial source for this disk + pub disk_source: DiskSource, + pub name: Name, + ///total size of the Disk in bytes + pub size: ByteCount, + } + + impl ::std::convert::From<&DiskCreate> for DiskCreate { + fn from(value: &DiskCreate) -> Self { + value.clone() + } + } + + ///TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "TODO-v1: Delete this Parameters for the + /// [`Disk`](omicron_common::api::external::Disk) to be attached or detached + /// to an instance", + /// "type": "object", + /// "required": [ + /// "name" + /// ], + /// "properties": { + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskIdentifier { + pub name: Name, + } + + impl ::std::convert::From<&DiskIdentifier> for DiskIdentifier { + fn from(value: &DiskIdentifier) -> Self { + value.clone() + } + } + + ///`DiskMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "activated", + /// "flush", + /// "read", + /// "read_bytes", + /// "write", + /// "write_bytes" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum DiskMetricName { + #[serde(rename = "activated")] + Activated, + #[serde(rename = "flush")] + Flush, + #[serde(rename = "read")] + Read, + #[serde(rename = "read_bytes")] + ReadBytes, + #[serde(rename = "write")] + Write, + #[serde(rename = "write_bytes")] + WriteBytes, + } + + impl ::std::convert::From<&Self> for DiskMetricName { + fn from(value: &DiskMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for DiskMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Activated => f.write_str("activated"), + Self::Flush => f.write_str("flush"), + Self::Read => f.write_str("read"), + Self::ReadBytes => f.write_str("read_bytes"), + Self::Write => f.write_str("write"), + Self::WriteBytes => f.write_str("write_bytes"), + } + } + } + + impl ::std::str::FromStr for DiskMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "activated" => Ok(Self::Activated), + "flush" => Ok(Self::Flush), + "read" => Ok(Self::Read), + "read_bytes" => Ok(Self::ReadBytes), + "write" => Ok(Self::Write), + "write_bytes" => Ok(Self::WriteBytes), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for DiskMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`DiskPath` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk" + /// ], + /// "properties": { + /// "disk": { + /// "$ref": "#/components/schemas/NameOrId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskPath { + pub disk: NameOrId, + } + + impl ::std::convert::From<&DiskPath> for DiskPath { + fn from(value: &DiskPath) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Disk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&DiskResultsPage> for DiskResultsPage { + fn from(value: &DiskResultsPage) -> Self { + value.clone() + } + } + + ///Different sources for a disk + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Different sources for a disk", + /// "oneOf": [ + /// { + /// "description": "Create a blank disk", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks for this Disk. valid values are: + /// 512, 2048, or 4096", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "blank" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a disk snapshot", + /// "type": "object", + /// "required": [ + /// "snapshot_id", + /// "type" + /// ], + /// "properties": { + /// "snapshot_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a project image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "image" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Create a disk from a global image", + /// "type": "object", + /// "required": [ + /// "image_id", + /// "type" + /// ], + /// "properties": { + /// "image_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "global_image" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum DiskSource { + ///Create a blank disk + #[serde(rename = "blank")] + Blank { + ///size of blocks for this Disk. valid values are: 512, 2048, or + /// 4096 + block_size: BlockSize, + }, + ///Create a disk from a disk snapshot + #[serde(rename = "snapshot")] + Snapshot { snapshot_id: ::uuid::Uuid }, + ///Create a disk from a project image + #[serde(rename = "image")] + Image { image_id: ::uuid::Uuid }, + ///Create a disk from a global image + #[serde(rename = "global_image")] + GlobalImage { image_id: ::uuid::Uuid }, + } + + impl ::std::convert::From<&Self> for DiskSource { + fn from(value: &DiskSource) -> Self { + value.clone() + } + } + + ///State of a Disk (primarily: attached or not) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "State of a Disk (primarily: attached or not)", + /// "oneOf": [ + /// { + /// "description": "Disk is being initialized", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is ready but detached from any Instance", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is attached to the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "attached" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is being detached from the given Instance", + /// "type": "object", + /// "required": [ + /// "instance", + /// "state" + /// ], + /// "properties": { + /// "instance": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "detaching" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk has been destroyed", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Disk is unavailable", + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "faulted" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "state", content = "instance")] + pub enum DiskState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "detached")] + Detached, + ///Disk is being attached to the given Instance + #[serde(rename = "attaching")] + Attaching(::uuid::Uuid), + ///Disk is attached to the given Instance + #[serde(rename = "attached")] + Attached(::uuid::Uuid), + ///Disk is being detached from the given Instance + #[serde(rename = "detaching")] + Detaching(::uuid::Uuid), + #[serde(rename = "destroyed")] + Destroyed, + #[serde(rename = "faulted")] + Faulted, + } + + impl ::std::convert::From<&Self> for DiskState { + fn from(value: &DiskState) -> Self { + value.clone() + } + } + + ///OS image distribution + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "OS image distribution", + /// "type": "object", + /// "required": [ + /// "name", + /// "version" + /// ], + /// "properties": { + /// "name": { + /// "description": "The name of the distribution (e.g. \"alpine\" or + /// \"ubuntu\")", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "version": { + /// "description": "The version of the distribution (e.g. \"3.10\" or + /// \"18.04\")", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Distribution { + ///The name of the distribution (e.g. "alpine" or "ubuntu") + pub name: Name, + ///The version of the distribution (e.g. "3.10" or "18.04") + pub version: ::std::string::String, + } + + impl ::std::convert::From<&Distribution> for Distribution { + fn from(value: &Distribution) -> Self { + value.clone() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + ///`ExternalIp` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "ip", + /// "kind" + /// ], + /// "properties": { + /// "ip": { + /// "type": "string", + /// "format": "ip" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/IpKind" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ExternalIp { + pub ip: ::std::net::IpAddr, + pub kind: IpKind, + } + + impl ::std::convert::From<&ExternalIp> for ExternalIp { + fn from(value: &ExternalIp) -> Self { + value.clone() + } + } + + ///Parameters for creating an external IP address for instances. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for creating an external IP address for + /// instances.", + /// "oneOf": [ + /// { + /// "description": "An IP address providing both inbound and outbound + /// access. The address is automatically-assigned from the provided IP Pool, + /// or all available pools if not specified.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "pool_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ephemeral" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum ExternalIpCreate { + ///An IP address providing both inbound and outbound access. The + /// address is automatically-assigned from the provided IP Pool, or all + /// available pools if not specified. + #[serde(rename = "ephemeral")] + Ephemeral { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pool_name: ::std::option::Option, + }, + } + + impl ::std::convert::From<&Self> for ExternalIpCreate { + fn from(value: &ExternalIpCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIp" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ExternalIpResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ExternalIpResultsPage> for ExternalIpResultsPage { + fn from(value: &ExternalIpResultsPage) -> Self { + value.clone() + } + } + + ///The name and type information for a field of a timeseries schema. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The name and type information for a field of a + /// timeseries schema.", + /// "type": "object", + /// "required": [ + /// "name", + /// "source", + /// "ty" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "source": { + /// "$ref": "#/components/schemas/FieldSource" + /// }, + /// "ty": { + /// "$ref": "#/components/schemas/FieldType" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FieldSchema { + pub name: ::std::string::String, + pub source: FieldSource, + pub ty: FieldType, + } + + impl ::std::convert::From<&FieldSchema> for FieldSchema { + fn from(value: &FieldSchema) -> Self { + value.clone() + } + } + + ///The source from which a field is derived, the target or metric. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source from which a field is derived, the target or + /// metric.", + /// "type": "string", + /// "enum": [ + /// "target", + /// "metric" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FieldSource { + #[serde(rename = "target")] + Target, + #[serde(rename = "metric")] + Metric, + } + + impl ::std::convert::From<&Self> for FieldSource { + fn from(value: &FieldSource) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Target => f.write_str("target"), + Self::Metric => f.write_str("metric"), + } + } + } + + impl ::std::str::FromStr for FieldSource { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "target" => Ok(Self::Target), + "metric" => Ok(Self::Metric), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldSource { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldSource { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The `FieldType` identifies the data type of a target or metric field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `FieldType` identifies the data type of a target or + /// metric field.", + /// "type": "string", + /// "enum": [ + /// "string", + /// "i64", + /// "ip_addr", + /// "uuid", + /// "bool" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FieldType { + #[serde(rename = "string")] + String, + #[serde(rename = "i64")] + I64, + #[serde(rename = "ip_addr")] + IpAddr, + #[serde(rename = "uuid")] + Uuid, + #[serde(rename = "bool")] + Bool, + } + + impl ::std::convert::From<&Self> for FieldType { + fn from(value: &FieldType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FieldType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::String => f.write_str("string"), + Self::I64 => f.write_str("i64"), + Self::IpAddr => f.write_str("ip_addr"), + Self::Uuid => f.write_str("uuid"), + Self::Bool => f.write_str("bool"), + } + } + } + + impl ::std::str::FromStr for FieldType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "string" => Ok(Self::String), + "i64" => Ok(Self::I64), + "ip_addr" => Ok(Self::IpAddr), + "uuid" => Ok(Self::Uuid), + "bool" => Ok(Self::Bool), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FieldType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FieldType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`FleetRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum FleetRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for FleetRole { + fn from(value: &FleetRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for FleetRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for FleetRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for FleetRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for FleetRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FleetRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FleetRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&FleetRolePolicy> for FleetRolePolicy { + fn from(value: &FleetRolePolicy) -> Self { + value.clone() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/FleetRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct FleetRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: FleetRole, + } + + impl ::std::convert::From<&FleetRoleRoleAssignment> for FleetRoleRoleAssignment { + fn from(value: &FleetRoleRoleAssignment) -> Self { + value.clone() + } + } + + ///Client view of global Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of global Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "id", + /// "name", + /// "size", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "distribution": { + /// "description": "Image distribution", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Image version", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImage { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///Image distribution + pub distribution: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Image version + pub version: ::std::string::String, + } + + impl ::std::convert::From<&GlobalImage> for GlobalImage { + fn from(value: &GlobalImage) -> Self { + value.clone() + } + } + + ///Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`GlobalImage`](crate::external_api::views::GlobalImage)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "distribution", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "distribution": { + /// "description": "OS image distribution", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Distribution" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + ///OS image distribution + pub distribution: Distribution, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&GlobalImageCreate> for GlobalImageCreate { + fn from(value: &GlobalImageCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/GlobalImage" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GlobalImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GlobalImageResultsPage> for GlobalImageResultsPage { + fn from(value: &GlobalImageResultsPage) -> Self { + value.clone() + } + } + + ///Client view of a [`Group`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Group`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the group", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this group belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Group { + ///Human-readable name that can identify the group + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this group belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&Group> for Group { + fn from(value: &Group) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Group" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct GroupResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&GroupResultsPage> for GroupResultsPage { + fn from(value: &GroupResultsPage) -> Self { + value.clone() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Bindouble" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Histogramdouble { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramdouble> for Histogramdouble { + fn from(value: &Histogramdouble) -> Self { + value.clone() + } + } + + ///A simple type for managing a histogram metric. + /// + ///A histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any "gaps" in the bins, and an additional bin + /// may be added to the left, right, or both so that the bins extend to the + /// entire range of the support. + /// + ///Note that any gaps, unsorted bins, or non-finite values will result in + /// an error. + /// + ///Example ------- ```rust use oximeter::histogram::{BinRange, Histogram}; + /// + ///let edges = [0i64, 10, 20]; let mut hist = + /// Histogram::new(&edges).unwrap(); assert_eq!(hist.n_bins(), 4); // One + /// additional bin for the range (20..) assert_eq!(hist.n_samples(), 0); + /// hist.sample(4); hist.sample(100); assert_eq!(hist.n_samples(), 2); + /// + ///let data = hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this bin + /// + ///assert_eq!(data[1].range, BinRange::range(0, 10)); // The range `0..10` + /// assert_eq!(data[1].count, 1); // 4 is sampled into this bin ``` + /// + ///Notes ----- + /// + ///Histograms may be constructed either from their left bin edges, or from + /// a sequence of ranges. In either case, the left-most bin may be converted + /// upon construction. In particular, if the left-most value is not equal to + /// the minimum of the support, a new bin will be added from the minimum to + /// that provided value. If the left-most value _is_ the support's minimum, + /// because the provided bin was unbounded below, such as `(..0)`, then that + /// bin will be converted into one bounded below, `(MIN..0)` in this case. + /// + ///The short of this is that, most of the time, it shouldn't matter. If one + /// specifies the extremes of the support as their bins, be aware that the + /// left-most may be converted from a `BinRange::RangeTo` into a + /// `BinRange::Range`. In other words, the first bin of a histogram is + /// _always_ a `Bin::Range` or a `Bin::RangeFrom` after construction. In + /// fact, every bin is one of those variants, the `BinRange::RangeTo` is + /// only provided as a convenience during construction. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A simple type for managing a histogram metric.\n\nA + /// histogram maintains the count of any number of samples, over a set of + /// bins. Bins are specified on construction via their _left_ edges, + /// inclusive. There can't be any \"gaps\" in the bins, and an additional + /// bin may be added to the left, right, or both so that the bins extend to + /// the entire range of the support.\n\nNote that any gaps, unsorted bins, + /// or non-finite values will result in an error.\n\nExample ------- ```rust + /// use oximeter::histogram::{BinRange, Histogram};\n\nlet edges = [0i64, + /// 10, 20]; let mut hist = Histogram::new(&edges).unwrap(); + /// assert_eq!(hist.n_bins(), 4); // One additional bin for the range (20..) + /// assert_eq!(hist.n_samples(), 0); hist.sample(4); hist.sample(100); + /// assert_eq!(hist.n_samples(), 2);\n\nlet data = + /// hist.iter().collect::>(); assert_eq!(data[0].range, + /// BinRange::range(i64::MIN, 0)); // An additional bin for `..0` + /// assert_eq!(data[0].count, 0); // Nothing is in this + /// bin\n\nassert_eq!(data[1].range, BinRange::range(0, 10)); // The range + /// `0..10` assert_eq!(data[1].count, 1); // 4 is sampled into this bin + /// ```\n\nNotes -----\n\nHistograms may be constructed either from their + /// left bin edges, or from a sequence of ranges. In either case, the + /// left-most bin may be converted upon construction. In particular, if the + /// left-most value is not equal to the minimum of the support, a new bin + /// will be added from the minimum to that provided value. If the left-most + /// value _is_ the support's minimum, because the provided bin was unbounded + /// below, such as `(..0)`, then that bin will be converted into one bounded + /// below, `(MIN..0)` in this case.\n\nThe short of this is that, most of + /// the time, it shouldn't matter. If one specifies the extremes of the + /// support as their bins, be aware that the left-most may be converted from + /// a `BinRange::RangeTo` into a `BinRange::Range`. In other words, the + /// first bin of a histogram is _always_ a `Bin::Range` or a + /// `Bin::RangeFrom` after construction. In fact, every bin is one of those + /// variants, the `BinRange::RangeTo` is only provided as a convenience + /// during construction.", + /// "type": "object", + /// "required": [ + /// "bins", + /// "n_samples", + /// "start_time" + /// ], + /// "properties": { + /// "bins": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Binint64" + /// } + /// }, + /// "n_samples": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "start_time": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Histogramint64 { + pub bins: ::std::vec::Vec, + pub n_samples: u64, + pub start_time: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Histogramint64> for Histogramint64 { + fn from(value: &Histogramint64) -> Self { + value.clone() + } + } + + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by id + /// only.\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdSortMode { + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for IdSortMode { + fn from(value: &IdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for IdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of an [`IdentityProvider`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`IdentityProvider`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "provider_type", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "provider_type": { + /// "description": "Identity provider type", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdentityProviderType" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IdentityProvider { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///Identity provider type + pub provider_type: IdentityProviderType, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IdentityProvider> for IdentityProvider { + fn from(value: &IdentityProvider) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IdentityProvider" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IdentityProviderResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IdentityProviderResultsPage> for IdentityProviderResultsPage { + fn from(value: &IdentityProviderResultsPage) -> Self { + value.clone() + } + } + + ///`IdentityProviderType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "description": "SAML identity provider", + /// "type": "string", + /// "enum": [ + /// "saml" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdentityProviderType { + ///SAML identity provider + #[serde(rename = "saml")] + Saml, + } + + impl ::std::convert::From<&Self> for IdentityProviderType { + fn from(value: &IdentityProviderType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityProviderType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Saml => f.write_str("saml"), + } + } + } + + impl ::std::str::FromStr for IdentityProviderType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml" => Ok(Self::Saml), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityProviderType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Describes what kind of identity is described by an id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes what kind of identity is described by an id", + /// "type": "string", + /// "enum": [ + /// "silo_user", + /// "silo_group" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IdentityType { + #[serde(rename = "silo_user")] + SiloUser, + #[serde(rename = "silo_group")] + SiloGroup, + } + + impl ::std::convert::From<&Self> for IdentityType { + fn from(value: &IdentityType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IdentityType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SiloUser => f.write_str("silo_user"), + Self::SiloGroup => f.write_str("silo_group"), + } + } + } + + impl ::std::str::FromStr for IdentityType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "silo_user" => Ok(Self::SiloUser), + "silo_group" => Ok(Self::SiloGroup), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IdentityType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IdentityType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IdpMetadataSource` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "data", + /// "type" + /// ], + /// "properties": { + /// "data": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "base64_encoded_xml" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum IdpMetadataSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "base64_encoded_xml")] + Base64EncodedXml { data: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for IdpMetadataSource { + fn from(value: &IdpMetadataSource) -> Self { + value.clone() + } + } + + ///Client view of project Images + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of project Images", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "size of blocks in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "digest": { + /// "description": "Hash of the image contents, if applicable", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Digest" + /// } + /// ] + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "The project the disk belongs to", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "description": "total size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "url": { + /// "description": "URL source of this image, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "version": { + /// "description": "Version of this, if any", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Image { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub digest: ::std::option::Option, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///The project the disk belongs to + pub project_id: ::uuid::Uuid, + ///total size in bytes + pub size: ByteCount, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub url: ::std::option::Option<::std::string::String>, + ///Version of this, if any + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub version: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&Image> for Image { + fn from(value: &Image) -> Self { + value.clone() + } + } + + ///Create-time parameters for an + /// [`Image`](crate::external_api::views::Image) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Image`](crate::external_api::views::Image)", + /// "type": "object", + /// "required": [ + /// "block_size", + /// "description", + /// "name", + /// "source" + /// ], + /// "properties": { + /// "block_size": { + /// "description": "block size in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/BlockSize" + /// } + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "source": { + /// "description": "The source of the image's contents.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ImageSource" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: ::std::string::String, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + impl ::std::convert::From<&ImageCreate> for ImageCreate { + fn from(value: &ImageCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Image" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ImageResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ImageResultsPage> for ImageResultsPage { + fn from(value: &ImageResultsPage) -> Self { + value.clone() + } + } + + ///The source of the underlying image. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The source of the underlying image.", + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "type", + /// "url" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "id", + /// "type" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "snapshot" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Boot the Alpine ISO that ships with the Propolis + /// zone. Intended for development purposes only.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "you_can_boot_anything_as_long_as_its_alpine" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum ImageSource { + #[serde(rename = "url")] + Url { url: ::std::string::String }, + #[serde(rename = "snapshot")] + Snapshot { id: ::uuid::Uuid }, + #[serde(rename = "you_can_boot_anything_as_long_as_its_alpine")] + YouCanBootAnythingAsLongAsItsAlpine, + } + + impl ::std::convert::From<&Self> for ImageSource { + fn from(value: &ImageSource) -> Self { + value.clone() + } + } + + ///Client view of an [`Instance`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Instance`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "id", + /// "memory", + /// "name", + /// "ncpus", + /// "project_id", + /// "run_state", + /// "time_created", + /// "time_modified", + /// "time_run_state_updated" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "hostname": { + /// "description": "RFC1035-compliant hostname for the Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "memory allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "ncpus": { + /// "description": "number of CPUs allocated for this Instance", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this Instance", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "run_state": { + /// "$ref": "#/components/schemas/InstanceState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_run_state_updated": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Instance { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///RFC1035-compliant hostname for the Instance. + pub hostname: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///memory allocated for this Instance + pub memory: ByteCount, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///number of CPUs allocated for this Instance + pub ncpus: InstanceCpuCount, + ///id for the project containing this Instance + pub project_id: ::uuid::Uuid, + pub run_state: InstanceState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub time_run_state_updated: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + ///The number of CPUs in an Instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The number of CPUs in an Instance", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct InstanceCpuCount(pub u16); + impl ::std::ops::Deref for InstanceCpuCount { + type Target = u16; + fn deref(&self) -> &u16 { + &self.0 + } + } + + impl ::std::convert::From for u16 { + fn from(value: InstanceCpuCount) -> Self { + value.0 + } + } + + impl ::std::convert::From<&InstanceCpuCount> for InstanceCpuCount { + fn from(value: &InstanceCpuCount) -> Self { + value.clone() + } + } + + impl ::std::convert::From for InstanceCpuCount { + fn from(value: u16) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for InstanceCpuCount { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for InstanceCpuCount { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for InstanceCpuCount { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "description", + /// "hostname", + /// "memory", + /// "name", + /// "ncpus" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disks": { + /// "description": "The disks to be created or attached for this + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/InstanceDiskAttachment" + /// } + /// }, + /// "external_ips": { + /// "description": "The external IP addresses provided to this + /// instance.\n\nBy default, all instances have outbound connectivity, but + /// no inbound connectivity. These external addresses can be used to provide + /// a fixed, known IP address for making inbound connections to the + /// instance.", + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ExternalIpCreate" + /// } + /// }, + /// "hostname": { + /// "type": "string" + /// }, + /// "memory": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ncpus": { + /// "$ref": "#/components/schemas/InstanceCpuCount" + /// }, + /// "network_interfaces": { + /// "description": "The network interfaces to be created for this + /// instance.", + /// "default": { + /// "type": "default" + /// }, + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceNetworkInterfaceAttachment" + /// } + /// ] + /// }, + /// "start": { + /// "description": "Should this instance be started upon creation; true + /// by default.", + /// "default": true, + /// "type": "boolean" + /// }, + /// "user_data": { + /// "description": "User data for instance initialization systems (such + /// as cloud-init). Must be a Base64-encoded string, as specified in RFC + /// 4648 § 4 (+ and / characters with padding). Maximum 32 KiB unencoded + /// data.", + /// "default": "", + /// "type": "string", + /// "format": "byte" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceCreate { + pub description: ::std::string::String, + ///The disks to be created or attached for this instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + ///The external IP addresses provided to this instance. + /// + ///By default, all instances have outbound connectivity, but no inbound + /// connectivity. These external addresses can be used to provide a + /// fixed, known IP address for making inbound connections to the + /// instance. + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub external_ips: ::std::vec::Vec, + pub hostname: ::std::string::String, + pub memory: ByteCount, + pub name: Name, + pub ncpus: InstanceCpuCount, + ///The network interfaces to be created for this instance. + #[serde(default = "defaults::instance_create_network_interfaces")] + pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///Should this instance be started upon creation; true by default. + #[serde(default = "defaults::default_bool::")] + pub start: bool, + ///User data for instance initialization systems (such as cloud-init). + /// Must be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and + /// / characters with padding). Maximum 32 KiB unencoded data. + #[serde(default)] + pub user_data: ::std::string::String, + } + + impl ::std::convert::From<&InstanceCreate> for InstanceCreate { + fn from(value: &InstanceCreate) -> Self { + value.clone() + } + } + + ///Describe the instance's disks at creation time + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describe the instance's disks at creation time", + /// "oneOf": [ + /// { + /// "description": "During instance creation, create and attach disks", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_source", + /// "name", + /// "size", + /// "type" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk_source": { + /// "description": "initial source for this disk", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DiskSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "size": { + /// "description": "total size of the Disk in bytes", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/ByteCount" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "During instance creation, attach this disk", + /// "type": "object", + /// "required": [ + /// "name", + /// "type" + /// ], + /// "properties": { + /// "name": { + /// "description": "A disk name to attach", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "attach" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum InstanceDiskAttachment { + ///During instance creation, create and attach disks + #[serde(rename = "create")] + Create { + description: ::std::string::String, + ///initial source for this disk + disk_source: DiskSource, + name: Name, + ///total size of the Disk in bytes + size: ByteCount, + }, + ///During instance creation, attach this disk + #[serde(rename = "attach")] + Attach { + ///A disk name to attach + name: Name, + }, + } + + impl ::std::convert::From<&Self> for InstanceDiskAttachment { + fn from(value: &InstanceDiskAttachment) -> Self { + value.clone() + } + } + + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance)", + /// "type": "object", + /// "required": [ + /// "dst_sled_id" + /// ], + /// "properties": { + /// "dst_sled_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrate { + pub dst_sled_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrate> for InstanceMigrate { + fn from(value: &InstanceMigrate) -> Self { + value.clone() + } + } + + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes an attachment of a `NetworkInterface` to an + /// `Instance`, at the time the instance is created.", + /// "oneOf": [ + /// { + /// "description": "Create one or more `NetworkInterface`s for the + /// `Instance`.\n\nIf more than one interface is provided, then the first + /// will be designated the primary interface for the instance.", + /// "type": "object", + /// "required": [ + /// "params", + /// "type" + /// ], + /// "properties": { + /// "params": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceCreate" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "create" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "The default networking configuration for an + /// instance is to create a single primary interface with an + /// automatically-assigned IP address. The IP will be pulled from the + /// Project's default VPC / VPC Subnet.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "No network interfaces at all will be created for + /// the instance.", + /// "type": "object", + /// "required": [ + /// "type" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "none" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "params")] + pub enum InstanceNetworkInterfaceAttachment { + ///Create one or more `NetworkInterface`s for the `Instance`. + /// + ///If more than one interface is provided, then the first will be + /// designated the primary interface for the instance. + #[serde(rename = "create")] + Create(::std::vec::Vec), + #[serde(rename = "default")] + Default, + #[serde(rename = "none")] + None, + } + + impl ::std::convert::From<&Self> for InstanceNetworkInterfaceAttachment { + fn from(value: &InstanceNetworkInterfaceAttachment) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::vec::Vec> + for InstanceNetworkInterfaceAttachment + { + fn from(value: ::std::vec::Vec) -> Self { + Self::Create(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&InstanceResultsPage> for InstanceResultsPage { + fn from(value: &InstanceResultsPage) -> Self { + value.clone() + } + } + + ///Contents of an Instance's serial console buffer. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Contents of an Instance's serial console buffer.", + /// "type": "object", + /// "required": [ + /// "data", + /// "last_byte_offset" + /// ], + /// "properties": { + /// "data": { + /// "description": "The bytes starting from the requested offset up to + /// either the end of the buffer or the request's `max_bytes`. Provided as a + /// u8 array rather than a string, as it may not be UTF-8.", + /// "type": "array", + /// "items": { + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// }, + /// "last_byte_offset": { + /// "description": "The absolute offset since boot (suitable for use as + /// `byte_offset` in a subsequent request) of the last byte returned in + /// `data`.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceSerialConsoleData { + ///The bytes starting from the requested offset up to either the end of + /// the buffer or the request's `max_bytes`. Provided as a u8 array + /// rather than a string, as it may not be UTF-8. + pub data: ::std::vec::Vec, + ///The absolute offset since boot (suitable for use as `byte_offset` in + /// a subsequent request) of the last byte returned in `data`. + pub last_byte_offset: u64, + } + + impl ::std::convert::From<&InstanceSerialConsoleData> for InstanceSerialConsoleData { + fn from(value: &InstanceSerialConsoleData) -> Self { + value.clone() + } + } + + ///Running state of an Instance (primarily: booted or stopped) + /// + ///This typically reflects whether it's starting, running, stopping, or + /// stopped, but also includes states related to the Instance's lifecycle + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Running state of an Instance (primarily: booted or + /// stopped)\n\nThis typically reflects whether it's starting, running, + /// stopping, or stopped, but also includes states related to the Instance's + /// lifecycle", + /// "oneOf": [ + /// { + /// "description": "The instance is being created.", + /// "type": "string", + /// "enum": [ + /// "creating" + /// ] + /// }, + /// { + /// "description": "The instance is currently starting up.", + /// "type": "string", + /// "enum": [ + /// "starting" + /// ] + /// }, + /// { + /// "description": "The instance is currently running.", + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// }, + /// { + /// "description": "The instance has been requested to stop and a + /// transition to \"Stopped\" is imminent.", + /// "type": "string", + /// "enum": [ + /// "stopping" + /// ] + /// }, + /// { + /// "description": "The instance is currently stopped.", + /// "type": "string", + /// "enum": [ + /// "stopped" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of rebooting - it + /// will remain in the \"rebooting\" state until the VM is starting once + /// more.", + /// "type": "string", + /// "enum": [ + /// "rebooting" + /// ] + /// }, + /// { + /// "description": "The instance is in the process of migrating - it will remain in the \"migrating\" state until the migration process is complete and the destination propolis is ready to continue execution.", + /// "type": "string", + /// "enum": [ + /// "migrating" + /// ] + /// }, + /// { + /// "description": "The instance is attempting to recover from a + /// failure.", + /// "type": "string", + /// "enum": [ + /// "repairing" + /// ] + /// }, + /// { + /// "description": "The instance has encountered a failure.", + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// }, + /// { + /// "description": "The instance has been deleted.", + /// "type": "string", + /// "enum": [ + /// "destroyed" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceState { + ///The instance is being created. + #[serde(rename = "creating")] + Creating, + ///The instance is currently starting up. + #[serde(rename = "starting")] + Starting, + ///The instance is currently running. + #[serde(rename = "running")] + Running, + ///The instance has been requested to stop and a transition to + /// "Stopped" is imminent. + #[serde(rename = "stopping")] + Stopping, + ///The instance is currently stopped. + #[serde(rename = "stopped")] + Stopped, + ///The instance is in the process of rebooting - it will remain in the + /// "rebooting" state until the VM is starting once more. + #[serde(rename = "rebooting")] + Rebooting, + ///The instance is in the process of migrating - it will remain in the + /// "migrating" state until the migration process is complete and the + /// destination propolis is ready to continue execution. + #[serde(rename = "migrating")] + Migrating, + ///The instance is attempting to recover from a failure. + #[serde(rename = "repairing")] + Repairing, + ///The instance has encountered a failure. + #[serde(rename = "failed")] + Failed, + ///The instance has been deleted. + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Starting => f.write_str("starting"), + Self::Running => f.write_str("running"), + Self::Stopping => f.write_str("stopping"), + Self::Stopped => f.write_str("stopped"), + Self::Rebooting => f.write_str("rebooting"), + Self::Migrating => f.write_str("migrating"), + Self::Repairing => f.write_str("repairing"), + Self::Failed => f.write_str("failed"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "starting" => Ok(Self::Starting), + "running" => Ok(Self::Running), + "stopping" => Ok(Self::Stopping), + "stopped" => Ok(Self::Stopped), + "rebooting" => Ok(Self::Rebooting), + "migrating" => Ok(Self::Migrating), + "repairing" => Ok(Self::Repairing), + "failed" => Ok(Self::Failed), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///The kind of an external IP address for an instance + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The kind of an external IP address for an instance", + /// "type": "string", + /// "enum": [ + /// "ephemeral", + /// "floating" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum IpKind { + #[serde(rename = "ephemeral")] + Ephemeral, + #[serde(rename = "floating")] + Floating, + } + + impl ::std::convert::From<&Self> for IpKind { + fn from(value: &IpKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for IpKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Ephemeral => f.write_str("ephemeral"), + Self::Floating => f.write_str("floating"), + } + } + } + + impl ::std::str::FromStr for IpKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "ephemeral" => Ok(Self::Ephemeral), + "floating" => Ok(Self::Floating), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for IpKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`IpNet` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum IpNet { + V4(Ipv4Net), + V6(Ipv6Net), + } + + impl ::std::convert::From<&Self> for IpNet { + fn from(value: &IpNet) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for IpNet { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::V4(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::V6(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for IpNet { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for IpNet { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for IpNet { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::V4(x) => x.fmt(f), + Self::V6(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv4Net) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpNet { + fn from(value: Ipv6Net) -> Self { + Self::V6(value) + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPool { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPool> for IpPool { + fn from(value: &IpPool) -> Self { + value.clone() + } + } + + ///Create-time parameters for an IP Pool. + /// + ///See [`IpPool`](crate::external_api::views::IpPool) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an IP Pool.\n\nSee + /// [`IpPool`](crate::external_api::views::IpPool)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&IpPoolCreate> for IpPoolCreate { + fn from(value: &IpPoolCreate) -> Self { + value.clone() + } + } + + ///`IpPoolRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "range", + /// "time_created" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "range": { + /// "$ref": "#/components/schemas/IpRange" + /// }, + /// "time_created": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolRange { + pub id: ::uuid::Uuid, + pub range: IpRange, + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&IpPoolRange> for IpPoolRange { + fn from(value: &IpPoolRange) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPoolRange" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolRangeResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolRangeResultsPage> for IpPoolRangeResultsPage { + fn from(value: &IpPoolRangeResultsPage) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/IpPool" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&IpPoolResultsPage> for IpPoolResultsPage { + fn from(value: &IpPoolResultsPage) -> Self { + value.clone() + } + } + + ///Parameters for updating an IP Pool + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating an IP Pool", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct IpPoolUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&IpPoolUpdate> for IpPoolUpdate { + fn from(value: &IpPoolUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for IpPoolUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + ///`IpRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "v4", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Range" + /// } + /// ] + /// }, + /// { + /// "title": "v6", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Range" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum IpRange { + V4(Ipv4Range), + V6(Ipv6Range), + } + + impl ::std::convert::From<&Self> for IpRange { + fn from(value: &IpRange) -> Self { + value.clone() + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv4Range) -> Self { + Self::V4(value) + } + } + + impl ::std::convert::From for IpRange { + fn from(value: Ipv6Range) -> Self { + Self::V6(value) + } + } + + ///An IPv4 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv4 subnet", + /// "description": "An IPv4 subnet, including prefix and subnet mask", + /// "examples": [ + /// "192.168.1.0/24" + /// ], + /// "type": "string", + /// "pattern": + /// "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\. + /// ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/ + /// ([8-9]|1[0-9]|2[0-9]|3[0-2])$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Ipv4Net(::std::string::String); + impl ::std::ops::Deref for Ipv4Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv4Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv4Net> for Ipv4Net { + fn from(value: &Ipv4Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv4Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ + ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv4Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv4Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv4 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv4 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv4" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv4" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Ipv4Range { + pub first: ::std::net::Ipv4Addr, + pub last: ::std::net::Ipv4Addr, + } + + impl ::std::convert::From<&Ipv4Range> for Ipv4Range { + fn from(value: &Ipv4Range) -> Self { + value.clone() + } + } + + ///An IPv6 subnet, including prefix and subnet mask + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "An IPv6 subnet", + /// "description": "An IPv6 subnet, including prefix and subnet mask", + /// "examples": [ + /// "fd12:3456::/64" + /// ], + /// "type": "string", + /// "pattern": + /// "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1, + /// 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Ipv6Net(::std::string::String); + impl ::std::ops::Deref for Ipv6Net { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Ipv6Net) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Ipv6Net> for Ipv6Net { + fn from(value: &Ipv6Net) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Ipv6Net { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ + 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Ipv6Net { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Ipv6Net { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A non-decreasing IPv6 address range, inclusive of both ends. + /// + ///The first address must be less than or equal to the last address. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A non-decreasing IPv6 address range, inclusive of both + /// ends.\n\nThe first address must be less than or equal to the last + /// address.", + /// "type": "object", + /// "required": [ + /// "first", + /// "last" + /// ], + /// "properties": { + /// "first": { + /// "type": "string", + /// "format": "ipv6" + /// }, + /// "last": { + /// "type": "string", + /// "format": "ipv6" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Ipv6Range { + pub first: ::std::net::Ipv6Addr, + pub last: ::std::net::Ipv6Addr, + } + + impl ::std::convert::From<&Ipv6Range> for Ipv6Range { + fn from(value: &Ipv6Range) -> Self { + value.clone() + } + } + + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A range of IP ports", + /// "description": "An inclusive-inclusive range of IP ports. The second + /// port may be omitted to represent a single port", + /// "examples": [ + /// "22" + /// ], + /// "type": "string", + /// "maxLength": 11, + /// "minLength": 1, + /// "pattern": "^[0-9]{1,5}(-[0-9]{1,5})?$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct L4PortRange(::std::string::String); + impl ::std::ops::Deref for L4PortRange { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: L4PortRange) -> Self { + value.0 + } + } + + impl ::std::convert::From<&L4PortRange> for L4PortRange { + fn from(value: &L4PortRange) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for L4PortRange { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 11usize { + return Err("longer than 11 characters".into()); + } + if value.chars().count() < 1usize { + return Err("shorter than 1 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for L4PortRange { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for L4PortRange { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A Media Access Control address, in EUI-48 format + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A MAC address", + /// "description": "A Media Access Control address, in EUI-48 format", + /// "examples": [ + /// "ff:ff:ff:ff:ff:ff" + /// ], + /// "type": "string", + /// "maxLength": 17, + /// "minLength": 17, + /// "pattern": "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct MacAddr(::std::string::String); + impl ::std::ops::Deref for MacAddr { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: MacAddr) -> Self { + value.0 + } + } + + impl ::std::convert::From<&MacAddr> for MacAddr { + fn from(value: &MacAddr) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for MacAddr { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 17usize { + return Err("longer than 17 characters".into()); + } + if value.chars().count() < 17usize { + return Err("shorter than 17 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for MacAddr { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MacAddr { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for MacAddr { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A `Measurement` is a timestamped datum from a single metric + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `Measurement` is a timestamped datum from a single + /// metric", + /// "type": "object", + /// "required": [ + /// "datum", + /// "timestamp" + /// ], + /// "properties": { + /// "datum": { + /// "$ref": "#/components/schemas/Datum" + /// }, + /// "timestamp": { + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Measurement { + pub datum: Datum, + pub timestamp: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Measurement> for Measurement { + fn from(value: &Measurement) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Measurement" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct MeasurementResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&MeasurementResultsPage> for MeasurementResultsPage { + fn from(value: &MeasurementResultsPage) -> Self { + value.clone() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Name(::std::string::String); + impl ::std::ops::Deref for Name { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Name) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Name> for Name { + fn from(value: &Name) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Name { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Name { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Name { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Name { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///`NameOrId` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "title": "id", + /// "allOf": [ + /// { + /// "type": "string", + /// "format": "uuid" + /// } + /// ] + /// }, + /// { + /// "title": "name", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(untagged)] + pub enum NameOrId { + Id(::uuid::Uuid), + Name(Name), + } + + impl ::std::convert::From<&Self> for NameOrId { + fn from(value: &NameOrId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for NameOrId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if let Ok(v) = value.parse() { + Ok(Self::Id(v)) + } else if let Ok(v) = value.parse() { + Ok(Self::Name(v)) + } else { + Err("string conversion failed for all variants".into()) + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for NameOrId { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match self { + Self::Id(x) => x.fmt(f), + Self::Name(x) => x.fmt(f), + } + } + } + + impl ::std::convert::From<::uuid::Uuid> for NameOrId { + fn from(value: ::uuid::Uuid) -> Self { + Self::Id(value) + } + } + + impl ::std::convert::From for NameOrId { + fn from(value: Name) -> Self { + Self::Name(value) + } + } + + ///Supported set of sort modes for scanning by name or id + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name or + /// id", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// }, + /// { + /// "description": "sort in decreasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_descending" + /// ] + /// }, + /// { + /// "description": "sort in increasing order of \"id\"", + /// "type": "string", + /// "enum": [ + /// "id_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum NameOrIdSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + ///sort in decreasing order of "name" + #[serde(rename = "name_descending")] + NameDescending, + ///sort in increasing order of "id" + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ::std::convert::From<&Self> for NameOrIdSortMode { + fn from(value: &NameOrIdSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameOrIdSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + Self::NameDescending => f.write_str("name_descending"), + Self::IdAscending => f.write_str("id_ascending"), + } + } + } + + impl ::std::str::FromStr for NameOrIdSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + "name_descending" => Ok(Self::NameDescending), + "id_ascending" => Ok(Self::IdAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameOrIdSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Supported set of sort modes for scanning by name + /// only\n\nCurrently, we only support scanning in ascending order.", + /// "oneOf": [ + /// { + /// "description": "sort in increasing order of \"name\"", + /// "type": "string", + /// "enum": [ + /// "name_ascending" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum NameSortMode { + ///sort in increasing order of "name" + #[serde(rename = "name_ascending")] + NameAscending, + } + + impl ::std::convert::From<&Self> for NameSortMode { + fn from(value: &NameSortMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for NameSortMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::NameAscending => f.write_str("name_ascending"), + } + } + } + + impl ::std::str::FromStr for NameSortMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "name_ascending" => Ok(Self::NameAscending), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for NameSortMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `NetworkInterface` represents a virtual network interface device. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `NetworkInterface` represents a virtual network + /// interface device.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "instance_id", + /// "ip", + /// "mac", + /// "name", + /// "primary", + /// "subnet_id", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "instance_id": { + /// "description": "The Instance to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ip": { + /// "description": "The IP address assigned to this interface.", + /// "type": "string", + /// "format": "ip" + /// }, + /// "mac": { + /// "description": "The MAC address assigned to this interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/MacAddr" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "primary": { + /// "description": "True if this interface is the primary for the + /// instance to which it's attached.", + /// "type": "boolean" + /// }, + /// "subnet_id": { + /// "description": "The subnet to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the interface belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterface { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The Instance to which the interface belongs. + pub instance_id: ::uuid::Uuid, + ///The IP address assigned to this interface. + pub ip: ::std::net::IpAddr, + ///The MAC address assigned to this interface. + pub mac: MacAddr, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///True if this interface is the primary for the instance to which it's + /// attached. + pub primary: bool, + ///The subnet to which the interface belongs. + pub subnet_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the interface belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`NetworkInterface`](omicron_common::api::external::NetworkInterface)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "subnet_name", + /// "vpc_name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ip": { + /// "description": "The IP address for the interface. One will be + /// auto-assigned if not provided.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "ip" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "subnet_name": { + /// "description": "The VPC Subnet in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "vpc_name": { + /// "description": "The VPC in which to create the interface.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceCreate { + pub description: ::std::string::String, + ///The IP address for the interface. One will be auto-assigned if not + /// provided. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ip: ::std::option::Option<::std::net::IpAddr>, + pub name: Name, + ///The VPC Subnet in which to create the interface. + pub subnet_name: Name, + ///The VPC in which to create the interface. + pub vpc_name: Name, + } + + impl ::std::convert::From<&NetworkInterfaceCreate> for NetworkInterfaceCreate { + fn from(value: &NetworkInterfaceCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&NetworkInterfaceResultsPage> for NetworkInterfaceResultsPage { + fn from(value: &NetworkInterfaceResultsPage) -> Self { + value.clone() + } + } + + ///Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface). + /// + ///Note that modifying IP addresses for an interface is not yet supported, + /// a new interface must be created instead. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for updating a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface).\ + /// n\nNote that modifying IP addresses for an interface is not yet + /// supported, a new interface must be created instead.", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "primary": { + /// "description": "Make a secondary interface the instance's primary + /// interface.\n\nIf applied to a secondary interface, that interface will + /// become the primary on the next reboot of the instance. Note that this + /// may have implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface.\n\nNote that this can only be used to select a new primary + /// interface for an instance. Requests to change the primary interface into + /// a secondary will return an error.", + /// "default": false, + /// "type": "boolean" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + ///Make a secondary interface the instance's primary interface. + /// + ///If applied to a secondary interface, that interface will become the + /// primary on the next reboot of the instance. Note that this may have + /// implications for routing between instances, as the new primary + /// interface will be on a distinct subnet from the previous primary + /// interface. + /// + ///Note that this can only be used to select a new primary interface + /// for an instance. Requests to change the primary interface into a + /// secondary will return an error. + #[serde(default)] + pub primary: bool, + } + + impl ::std::convert::From<&NetworkInterfaceUpdate> for NetworkInterfaceUpdate { + fn from(value: &NetworkInterfaceUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for NetworkInterfaceUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + primary: Default::default(), + } + } + } + + ///Unique name for a saga [`Node`] + /// + ///Each node requires a string name that's unique within its DAG. The name + /// is used to identify its output. Nodes that depend on a given node + /// (either directly or indirectly) can access the node's output using its + /// name. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Unique name for a saga [`Node`]\n\nEach node requires a + /// string name that's unique within its DAG. The name is used to identify + /// its output. Nodes that depend on a given node (either directly or + /// indirectly) can access the node's output using its name.", + /// "type": "string" + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + #[serde(transparent)] + pub struct NodeName(pub ::std::string::String); + impl ::std::ops::Deref for NodeName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: NodeName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&NodeName> for NodeName { + fn from(value: &NodeName) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::string::String> for NodeName { + fn from(value: ::std::string::String) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for NodeName { + type Err = ::std::convert::Infallible; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.to_string())) + } + } + + impl ::std::fmt::Display for NodeName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///Client view of an [`Organization`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Organization`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Organization { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Organization> for Organization { + fn from(value: &Organization) -> Self { + value.clone() + } + } + + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&OrganizationCreate> for OrganizationCreate { + fn from(value: &OrganizationCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Organization" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&OrganizationResultsPage> for OrganizationResultsPage { + fn from(value: &OrganizationResultsPage) -> Self { + value.clone() + } + } + + ///`OrganizationRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum OrganizationRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for OrganizationRole { + fn from(value: &OrganizationRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for OrganizationRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for OrganizationRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for OrganizationRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/OrganizationRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&OrganizationRolePolicy> for OrganizationRolePolicy { + fn from(value: &OrganizationRolePolicy) -> Self { + value.clone() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/OrganizationRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: OrganizationRole, + } + + impl ::std::convert::From<&OrganizationRoleRoleAssignment> for OrganizationRoleRoleAssignment { + fn from(value: &OrganizationRoleRoleAssignment) -> Self { + value.clone() + } + } + + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct OrganizationUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&OrganizationUpdate> for OrganizationUpdate { + fn from(value: &OrganizationUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for OrganizationUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + ///Passwords may be subject to additional constraints. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A password used to authenticate a user", + /// "description": "Passwords may be subject to additional constraints.", + /// "type": "string", + /// "maxLength": 512 + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct Password(::std::string::String); + impl ::std::ops::Deref for Password { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: Password) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Password> for Password { + fn from(value: &Password) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for Password { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 512usize { + return Err("longer than 512 characters".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for Password { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for Password { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for Password { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Client view of a [`PhysicalDisk`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`PhysicalDisk`]", + /// "type": "object", + /// "required": [ + /// "disk_type", + /// "id", + /// "model", + /// "serial", + /// "time_created", + /// "time_modified", + /// "vendor" + /// ], + /// "properties": { + /// "disk_type": { + /// "$ref": "#/components/schemas/PhysicalDiskType" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "model": { + /// "type": "string" + /// }, + /// "serial": { + /// "type": "string" + /// }, + /// "sled_id": { + /// "description": "The sled to which this disk is attached, if any.", + /// "type": [ + /// "string", + /// "null" + /// ], + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vendor": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PhysicalDisk { + pub disk_type: PhysicalDiskType, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub model: ::std::string::String, + pub serial: ::std::string::String, + ///The sled to which this disk is attached, if any. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub sled_id: ::std::option::Option<::uuid::Uuid>, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub vendor: ::std::string::String, + } + + impl ::std::convert::From<&PhysicalDisk> for PhysicalDisk { + fn from(value: &PhysicalDisk) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/PhysicalDisk" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct PhysicalDiskResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&PhysicalDiskResultsPage> for PhysicalDiskResultsPage { + fn from(value: &PhysicalDiskResultsPage) -> Self { + value.clone() + } + } + + ///`PhysicalDiskType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "internal", + /// "external" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum PhysicalDiskType { + #[serde(rename = "internal")] + Internal, + #[serde(rename = "external")] + External, + } + + impl ::std::convert::From<&Self> for PhysicalDiskType { + fn from(value: &PhysicalDiskType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for PhysicalDiskType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Internal => f.write_str("internal"), + Self::External => f.write_str("external"), + } + } + } + + impl ::std::str::FromStr for PhysicalDiskType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "internal" => Ok(Self::Internal), + "external" => Ok(Self::External), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for PhysicalDiskType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Project`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Project`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "organization_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "organization_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Project { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub organization_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Project> for Project { + fn from(value: &Project) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&ProjectCreate> for ProjectCreate { + fn from(value: &ProjectCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Project" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&ProjectResultsPage> for ProjectResultsPage { + fn from(value: &ProjectResultsPage) -> Self { + value.clone() + } + } + + ///`ProjectRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum ProjectRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for ProjectRole { + fn from(value: &ProjectRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ProjectRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for ProjectRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ProjectRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/ProjectRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&ProjectRolePolicy> for ProjectRolePolicy { + fn from(value: &ProjectRolePolicy) -> Self { + value.clone() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/ProjectRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: ProjectRole, + } + + impl ::std::convert::From<&ProjectRoleRoleAssignment> for ProjectRoleRoleAssignment { + fn from(value: &ProjectRoleRoleAssignment) -> Self { + value.clone() + } + } + + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Project`](crate::external_api::views::Project)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct ProjectUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&ProjectUpdate> for ProjectUpdate { + fn from(value: &ProjectUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for ProjectUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + ///Client view of an [`Rack`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of an [`Rack`]", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Rack { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Rack> for Rack { + fn from(value: &Rack) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Rack" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RackResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RackResultsPage> for RackResultsPage { + fn from(value: &RackResultsPage) -> Self { + value.clone() + } + } + + ///Client view of a [`Role`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Role`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/RoleName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Role { + pub description: ::std::string::String, + pub name: RoleName, + } + + impl ::std::convert::From<&Role> for Role { + fn from(value: &Role) -> Self { + value.clone() + } + } + + ///Role names consist of two string components separated by dot ("."). + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name for a built-in role", + /// "description": "Role names consist of two string components separated + /// by dot (\".\").", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": "[a-z-]+\\.[a-z-]+" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct RoleName(::std::string::String); + impl ::std::ops::Deref for RoleName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: RoleName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&RoleName> for RoleName { + fn from(value: &RoleName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for RoleName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| ::regress::Regex::new("[a-z-]+\\.[a-z-]+").unwrap()); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for RoleName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RoleName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for RoleName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Role" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RoleResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RoleResultsPage> for RoleResultsPage { + fn from(value: &RoleResultsPage) -> Self { + value.clone() + } + } + + ///A `RouteDestination` is used to match traffic with a routing rule, on + /// the destination of that traffic. + /// + ///When traffic is to be sent to a destination that is within a given + /// `RouteDestination`, the corresponding [`RouterRoute`] applies, and + /// traffic will be forward to the [`RouteTarget`] for that rule. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteDestination` is used to match traffic with a + /// routing rule, on the destination of that traffic.\n\nWhen traffic is to + /// be sent to a destination that is within a given `RouteDestination`, the + /// corresponding [`RouterRoute`] applies, and traffic will be forward to + /// the [`RouteTarget`] for that rule.", + /// "oneOf": [ + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic destined for the given + /// VPC.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Route applies to traffic", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum RouteDestination { + ///Route applies to traffic destined for a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Route applies to traffic destined for a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + ///Route applies to traffic destined for the given VPC. + #[serde(rename = "vpc")] + Vpc(Name), + ///Route applies to traffic + #[serde(rename = "subnet")] + Subnet(Name), + } + + impl ::std::convert::From<&Self> for RouteDestination { + fn from(value: &RouteDestination) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteDestination { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for RouteDestination { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `RouteTarget` describes the possible locations that + /// traffic matching a route destination can be sent.", + /// "oneOf": [ + /// { + /// "description": "Forward traffic to a particular IP address.", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to a specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "Forward traffic to an internet gateway", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "internet_gateway" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum RouteTarget { + ///Forward traffic to a particular IP address. + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///Forward traffic to a VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///Forward traffic to a VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///Forward traffic to a specific instance + #[serde(rename = "instance")] + Instance(Name), + ///Forward traffic to an internet gateway + #[serde(rename = "internet_gateway")] + InternetGateway(Name), + } + + impl ::std::convert::From<&Self> for RouteTarget { + fn from(value: &RouteTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for RouteTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A route defines a rule that governs where traffic + /// should be sent based on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "id", + /// "kind", + /// "name", + /// "target", + /// "time_created", + /// "time_modified", + /// "vpc_router_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "description": "Describes the kind of router. Set at creation. + /// `read-only`", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/RouterRouteKind" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_router_id": { + /// "description": "The VPC Router to which the route belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRoute { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub destination: RouteDestination, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///Describes the kind of router. Set at creation. `read-only` + pub kind: RouterRouteKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub target: RouteTarget, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC Router to which the route belongs. + pub vpc_router_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&RouterRoute> for RouterRoute { + fn from(value: &RouterRoute) -> Self { + value.clone() + } + } + + ///Create-time parameters for a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "destination", + /// "name", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteCreateParams { + pub description: ::std::string::String, + pub destination: RouteDestination, + pub name: Name, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteCreateParams> for RouterRouteCreateParams { + fn from(value: &RouterRouteCreateParams) -> Self { + value.clone() + } + } + + ///The classification of a [`RouterRoute`] as defined by the system. The + /// kind determines certain attributes such as if the route is modifiable + /// and describes how or where the route was created. + /// + ///See [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The classification of a [`RouterRoute`] as defined by the system. The kind determines certain attributes such as if the route is modifiable and describes how or where the route was created.\n\nSee [RFD-21](https://rfd.shared.oxide.computer/rfd/0021#concept-router) for more context", + /// "oneOf": [ + /// { + /// "description": "Determines the default destination of traffic, such + /// as whether it goes to the internet or not.\n\n`Destination: An Internet + /// Gateway` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "default" + /// ] + /// }, + /// { + /// "description": "Automatically added for each VPC Subnet in the + /// VPC\n\n`Destination: A VPC Subnet` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_subnet" + /// ] + /// }, + /// { + /// "description": "Automatically added when VPC peering is + /// established\n\n`Destination: A different VPC` `Modifiable: false`", + /// "type": "string", + /// "enum": [ + /// "vpc_peering" + /// ] + /// }, + /// { + /// "description": "Created by a user See + /// [`RouteTarget`]\n\n`Destination: User defined` `Modifiable: true`", + /// "type": "string", + /// "enum": [ + /// "custom" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum RouterRouteKind { + ///Determines the default destination of traffic, such as whether it + /// goes to the internet or not. + /// + ///`Destination: An Internet Gateway` `Modifiable: true` + #[serde(rename = "default")] + Default, + ///Automatically added for each VPC Subnet in the VPC + /// + ///`Destination: A VPC Subnet` `Modifiable: false` + #[serde(rename = "vpc_subnet")] + VpcSubnet, + ///Automatically added when VPC peering is established + /// + ///`Destination: A different VPC` `Modifiable: false` + #[serde(rename = "vpc_peering")] + VpcPeering, + ///Created by a user See [`RouteTarget`] + /// + ///`Destination: User defined` `Modifiable: true` + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for RouterRouteKind { + fn from(value: &RouterRouteKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for RouterRouteKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Default => f.write_str("default"), + Self::VpcSubnet => f.write_str("vpc_subnet"), + Self::VpcPeering => f.write_str("vpc_peering"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for RouterRouteKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "default" => Ok(Self::Default), + "vpc_subnet" => Ok(Self::VpcSubnet), + "vpc_peering" => Ok(Self::VpcPeering), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for RouterRouteKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/RouterRoute" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&RouterRouteResultsPage> for RouterRouteResultsPage { + fn from(value: &RouterRouteResultsPage) -> Self { + value.clone() + } + } + + ///Updateable properties of a [`RouterRoute`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a [`RouterRoute`]", + /// "type": "object", + /// "required": [ + /// "destination", + /// "target" + /// ], + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "destination": { + /// "$ref": "#/components/schemas/RouteDestination" + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "target": { + /// "$ref": "#/components/schemas/RouteTarget" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct RouterRouteUpdateParams { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + pub destination: RouteDestination, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + pub target: RouteTarget, + } + + impl ::std::convert::From<&RouterRouteUpdateParams> for RouterRouteUpdateParams { + fn from(value: &RouterRouteUpdateParams) -> Self { + value.clone() + } + } + + ///`Saga` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "state" + /// ], + /// "properties": { + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SagaState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Saga { + pub id: ::uuid::Uuid, + pub state: SagaState, + } + + impl ::std::convert::From<&Saga> for Saga { + fn from(value: &Saga) -> Self { + value.clone() + } + } + + ///`SagaErrorInfo` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "source_error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "action_failed" + /// ] + /// }, + /// "source_error": {} + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "deserialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "injected_error" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "serialize_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error", + /// "message" + /// ], + /// "properties": { + /// "error": { + /// "type": "string", + /// "enum": [ + /// "subsaga_create_failed" + /// ] + /// }, + /// "message": { + /// "type": "string" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "error")] + pub enum SagaErrorInfo { + #[serde(rename = "action_failed")] + ActionFailed { source_error: ::serde_json::Value }, + #[serde(rename = "deserialize_failed")] + DeserializeFailed { message: ::std::string::String }, + #[serde(rename = "injected_error")] + InjectedError, + #[serde(rename = "serialize_failed")] + SerializeFailed { message: ::std::string::String }, + #[serde(rename = "subsaga_create_failed")] + SubsagaCreateFailed { message: ::std::string::String }, + } + + impl ::std::convert::From<&Self> for SagaErrorInfo { + fn from(value: &SagaErrorInfo) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Saga" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SagaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SagaResultsPage> for SagaResultsPage { + fn from(value: &SagaResultsPage) -> Self { + value.clone() + } + } + + ///`SagaState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "running" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "type": "string", + /// "enum": [ + /// "succeeded" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "error_info", + /// "error_node_name", + /// "state" + /// ], + /// "properties": { + /// "error_info": { + /// "$ref": "#/components/schemas/SagaErrorInfo" + /// }, + /// "error_node_name": { + /// "$ref": "#/components/schemas/NodeName" + /// }, + /// "state": { + /// "type": "string", + /// "enum": [ + /// "failed" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "state")] + pub enum SagaState { + #[serde(rename = "running")] + Running, + #[serde(rename = "succeeded")] + Succeeded, + #[serde(rename = "failed")] + Failed { + error_info: SagaErrorInfo, + error_node_name: NodeName, + }, + } + + impl ::std::convert::From<&Self> for SagaState { + fn from(value: &SagaState) -> Self { + value.clone() + } + } + + ///Identity-related metadata that's included in nearly all public API + /// objects + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in nearly all + /// public API objects", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "id", + /// "idp_entity_id", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_cert": { + /// "description": "optional request signing public certificate (base64 + /// encoded der file)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SamlIdentityProvider { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///optional request signing public certificate (base64 encoded der + /// file) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub public_cert: ::std::option::Option<::std::string::String>, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SamlIdentityProvider> for SamlIdentityProvider { + fn from(value: &SamlIdentityProvider) -> Self { + value.clone() + } + } + + ///Create-time identity-related parameters + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time identity-related parameters", + /// "type": "object", + /// "required": [ + /// "acs_url", + /// "description", + /// "idp_entity_id", + /// "idp_metadata_source", + /// "name", + /// "slo_url", + /// "sp_client_id", + /// "technical_contact_email" + /// ], + /// "properties": { + /// "acs_url": { + /// "description": "service provider endpoint where the response will + /// be sent", + /// "type": "string" + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "group_attribute_name": { + /// "description": "If set, SAML attributes with this name will be + /// considered to denote a user's group membership, where the attribute + /// value(s) should be a comma-separated list of group names.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "idp_entity_id": { + /// "description": "idp's entity id", + /// "type": "string" + /// }, + /// "idp_metadata_source": { + /// "description": "the source of an identity provider metadata + /// descriptor", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/IdpMetadataSource" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "signing_keypair": { + /// "description": "optional request signing key pair", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/DerEncodedKeyPair" + /// } + /// ] + /// } + /// ] + /// }, + /// "slo_url": { + /// "description": "service provider endpoint where the idp should send + /// log out requests", + /// "type": "string" + /// }, + /// "sp_client_id": { + /// "description": "sp's client id", + /// "type": "string" + /// }, + /// "technical_contact_email": { + /// "description": "customer's technical contact for saml + /// configuration", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SamlIdentityProviderCreate { + ///service provider endpoint where the response will be sent + pub acs_url: ::std::string::String, + pub description: ::std::string::String, + ///If set, SAML attributes with this name will be considered to denote + /// a user's group membership, where the attribute value(s) should be a + /// comma-separated list of group names. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub group_attribute_name: ::std::option::Option<::std::string::String>, + ///idp's entity id + pub idp_entity_id: ::std::string::String, + ///the source of an identity provider metadata descriptor + pub idp_metadata_source: IdpMetadataSource, + pub name: Name, + ///optional request signing key pair + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub signing_keypair: ::std::option::Option, + ///service provider endpoint where the idp should send log out requests + pub slo_url: ::std::string::String, + ///sp's client id + pub sp_client_id: ::std::string::String, + ///customer's technical contact for saml configuration + pub technical_contact_email: ::std::string::String, + } + + impl ::std::convert::From<&SamlIdentityProviderCreate> for SamlIdentityProviderCreate { + fn from(value: &SamlIdentityProviderCreate) -> Self { + value.clone() + } + } + + ///`SemverVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "pattern": "^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct SemverVersion(::std::string::String); + impl ::std::ops::Deref for SemverVersion { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: SemverVersion) -> Self { + value.0 + } + } + + impl ::std::convert::From<&SemverVersion> for SemverVersion { + fn from(value: &SemverVersion) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for SemverVersion { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$").unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SemverVersion { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for SemverVersion { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The service intended to use this certificate. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The service intended to use this certificate.", + /// "oneOf": [ + /// { + /// "description": "This certificate is intended for access to the + /// external API.", + /// "type": "string", + /// "enum": [ + /// "external_api" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum ServiceUsingCertificate { + ///This certificate is intended for access to the external API. + #[serde(rename = "external_api")] + ExternalApi, + } + + impl ::std::convert::From<&Self> for ServiceUsingCertificate { + fn from(value: &ServiceUsingCertificate) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for ServiceUsingCertificate { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::ExternalApi => f.write_str("external_api"), + } + } + } + + impl ::std::str::FromStr for ServiceUsingCertificate { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "external_api" => Ok(Self::ExternalApi), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for ServiceUsingCertificate { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a ['Silo'] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a ['Silo']", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "id", + /// "identity_mode", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "discoverable": { + /// "description": "A silo where discoverable is false can be retrieved only by its id - it will not be part of the \"list all silos\" output.", + /// "type": "boolean" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_mode": { + /// "description": "How users and groups are managed in this Silo", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Silo { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///A silo where discoverable is false can be retrieved only by its id - + /// it will not be part of the "list all silos" output. + pub discoverable: bool, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///How users and groups are managed in this Silo + pub identity_mode: SiloIdentityMode, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Silo> for Silo { + fn from(value: &Silo) -> Self { + value.clone() + } + } + + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Silo`](crate::external_api::views::Silo)", + /// "type": "object", + /// "required": [ + /// "description", + /// "discoverable", + /// "identity_mode", + /// "name" + /// ], + /// "properties": { + /// "admin_group_name": { + /// "description": "If set, this group will be created during Silo + /// creation and granted the \"Silo Admin\" role. Identity providers can + /// assert that users belong to this group and those users can log in and + /// further initialize the Silo.\n\nNote that if configuring a SAML based + /// identity provider, group_attribute_name must be set for users to be + /// considered part of a group. See [`SamlIdentityProviderCreate`] for more + /// information.", + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "description": { + /// "type": "string" + /// }, + /// "discoverable": { + /// "type": "boolean" + /// }, + /// "identity_mode": { + /// "$ref": "#/components/schemas/SiloIdentityMode" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloCreate { + ///If set, this group will be created during Silo creation and granted + /// the "Silo Admin" role. Identity providers can assert that users + /// belong to this group and those users can log in and further + /// initialize the Silo. + /// + ///Note that if configuring a SAML based identity provider, + /// group_attribute_name must be set for users to be considered part of + /// a group. See [`SamlIdentityProviderCreate`] for more information. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub admin_group_name: ::std::option::Option<::std::string::String>, + pub description: ::std::string::String, + pub discoverable: bool, + pub identity_mode: SiloIdentityMode, + pub name: Name, + } + + impl ::std::convert::From<&SiloCreate> for SiloCreate { + fn from(value: &SiloCreate) -> Self { + value.clone() + } + } + + ///Describes how identities are managed and users are authenticated in this + /// Silo + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes how identities are managed and users are + /// authenticated in this Silo", + /// "oneOf": [ + /// { + /// "description": "Users are authenticated with SAML using an external + /// authentication provider. The system updates information about users and + /// groups only during successful authentication (i.e,. \"JIT provisioning\" + /// of users and groups).", + /// "type": "string", + /// "enum": [ + /// "saml_jit" + /// ] + /// }, + /// { + /// "description": "The system is the source of truth about users. + /// There is no linkage to an external authentication provider or identity + /// provider.", + /// "type": "string", + /// "enum": [ + /// "local_only" + /// ] + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SiloIdentityMode { + ///Users are authenticated with SAML using an external authentication + /// provider. The system updates information about users and groups + /// only during successful authentication (i.e,. "JIT provisioning" of + /// users and groups). + #[serde(rename = "saml_jit")] + SamlJit, + ///The system is the source of truth about users. There is no linkage + /// to an external authentication provider or identity provider. + #[serde(rename = "local_only")] + LocalOnly, + } + + impl ::std::convert::From<&Self> for SiloIdentityMode { + fn from(value: &SiloIdentityMode) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloIdentityMode { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::SamlJit => f.write_str("saml_jit"), + Self::LocalOnly => f.write_str("local_only"), + } + } + } + + impl ::std::str::FromStr for SiloIdentityMode { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "saml_jit" => Ok(Self::SamlJit), + "local_only" => Ok(Self::LocalOnly), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloIdentityMode { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Silo" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SiloResultsPage> for SiloResultsPage { + fn from(value: &SiloResultsPage) -> Self { + value.clone() + } + } + + ///`SiloRole` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "admin", + /// "collaborator", + /// "viewer" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SiloRole { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ::std::convert::From<&Self> for SiloRole { + fn from(value: &SiloRole) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SiloRole { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Admin => f.write_str("admin"), + Self::Collaborator => f.write_str("collaborator"), + Self::Viewer => f.write_str("viewer"), + } + } + } + + impl ::std::str::FromStr for SiloRole { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "admin" => Ok(Self::Admin), + "collaborator" => Ok(Self::Collaborator), + "viewer" => Ok(Self::Viewer), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SiloRole { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SiloRole { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`Policy`], which describes how this resource may be + /// accessed + /// + ///Note that the Policy only describes access granted explicitly for this + /// resource. The policies of parent resources can also cause a user to + /// have access to this resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Policy`], which describes how this + /// resource may be accessed\n\nNote that the Policy only describes access + /// granted explicitly for this resource. The policies of parent resources + /// can also cause a user to have access to this resource.", + /// "type": "object", + /// "required": [ + /// "role_assignments" + /// ], + /// "properties": { + /// "role_assignments": { + /// "description": "Roles directly assigned on this resource", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SiloRoleRoleAssignment" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloRolePolicy { + ///Roles directly assigned on this resource + pub role_assignments: ::std::vec::Vec, + } + + impl ::std::convert::From<&SiloRolePolicy> for SiloRolePolicy { + fn from(value: &SiloRolePolicy) -> Self { + value.clone() + } + } + + ///Describes the assignment of a particular role on a particular resource + /// to a particular identity (user, group, etc.) + /// + ///The resource is not part of this structure. Rather, [`RoleAssignment`]s + /// are put into a [`Policy`] and that Policy is applied to a particular + /// resource. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Describes the assignment of a particular role on a + /// particular resource to a particular identity (user, group, etc.)\n\nThe + /// resource is not part of this structure. Rather, [`RoleAssignment`]s are + /// put into a [`Policy`] and that Policy is applied to a particular + /// resource.", + /// "type": "object", + /// "required": [ + /// "identity_id", + /// "identity_type", + /// "role_name" + /// ], + /// "properties": { + /// "identity_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "identity_type": { + /// "$ref": "#/components/schemas/IdentityType" + /// }, + /// "role_name": { + /// "$ref": "#/components/schemas/SiloRole" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SiloRoleRoleAssignment { + pub identity_id: ::uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: SiloRole, + } + + impl ::std::convert::From<&SiloRoleRoleAssignment> for SiloRoleRoleAssignment { + fn from(value: &SiloRoleRoleAssignment) -> Self { + value.clone() + } + } + + ///Client view of a [`Sled`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Sled`]", + /// "type": "object", + /// "required": [ + /// "baseboard", + /// "id", + /// "service_address", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "baseboard": { + /// "$ref": "#/components/schemas/Baseboard" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "service_address": { + /// "type": "string" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Sled { + pub baseboard: Baseboard, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub service_address: ::std::string::String, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Sled> for Sled { + fn from(value: &Sled) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Sled" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SledResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SledResultsPage> for SledResultsPage { + fn from(value: &SledResultsPage) -> Self { + value.clone() + } + } + + ///Client view of a Snapshot + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a Snapshot", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk_id", + /// "id", + /// "name", + /// "project_id", + /// "size", + /// "state", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "size": { + /// "$ref": "#/components/schemas/ByteCount" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/SnapshotState" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Snapshot { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + pub disk_id: ::uuid::Uuid, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: ::uuid::Uuid, + pub size: ByteCount, + pub state: SnapshotState, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Snapshot> for Snapshot { + fn from(value: &Snapshot) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Snapshot`](crate::external_api::views::Snapshot)", + /// "type": "object", + /// "required": [ + /// "description", + /// "disk", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "disk": { + /// "description": "The name of the disk to be snapshotted", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SnapshotCreate { + pub description: ::std::string::String, + ///The name of the disk to be snapshotted + pub disk: Name, + pub name: Name, + } + + impl ::std::convert::From<&SnapshotCreate> for SnapshotCreate { + fn from(value: &SnapshotCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Snapshot" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SnapshotResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SnapshotResultsPage> for SnapshotResultsPage { + fn from(value: &SnapshotResultsPage) -> Self { + value.clone() + } + } + + ///`SnapshotState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "creating", + /// "ready", + /// "faulted", + /// "destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SnapshotState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "ready")] + Ready, + #[serde(rename = "faulted")] + Faulted, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ::std::convert::From<&Self> for SnapshotState { + fn from(value: &SnapshotState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SnapshotState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("creating"), + Self::Ready => f.write_str("ready"), + Self::Faulted => f.write_str("faulted"), + Self::Destroyed => f.write_str("destroyed"), + } + } + } + + impl ::std::str::FromStr for SnapshotState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "creating" => Ok(Self::Creating), + "ready" => Ok(Self::Ready), + "faulted" => Ok(Self::Faulted), + "destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SnapshotState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`SpoofLoginBody` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "username" + /// ], + /// "properties": { + /// "username": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SpoofLoginBody { + pub username: ::std::string::String, + } + + impl ::std::convert::From<&SpoofLoginBody> for SpoofLoginBody { + fn from(value: &SpoofLoginBody) -> Self { + value.clone() + } + } + + ///Client view of a [`SshKey`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`SshKey`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "public_key", + /// "silo_user_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// }, + /// "silo_user_id": { + /// "description": "The user to whom this key belongs", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKey { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + ///The user to whom this key belongs + pub silo_user_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&SshKey> for SshKey { + fn from(value: &SshKey) -> Self { + value.clone() + } + } + + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name", + /// "public_key" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "public_key": { + /// "description": "SSH public key, e.g., `\"ssh-ed25519 + /// AAAAC3NzaC...\"`", + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKeyCreate { + pub description: ::std::string::String, + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: ::std::string::String, + } + + impl ::std::convert::From<&SshKeyCreate> for SshKeyCreate { + fn from(value: &SshKeyCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SshKey" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SshKeyResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SshKeyResultsPage> for SshKeyResultsPage { + fn from(value: &SshKeyResultsPage) -> Self { + value.clone() + } + } + + ///`SystemMetricName` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "virtual_disk_space_provisioned", + /// "cpus_provisioned", + /// "ram_provisioned" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum SystemMetricName { + #[serde(rename = "virtual_disk_space_provisioned")] + VirtualDiskSpaceProvisioned, + #[serde(rename = "cpus_provisioned")] + CpusProvisioned, + #[serde(rename = "ram_provisioned")] + RamProvisioned, + } + + impl ::std::convert::From<&Self> for SystemMetricName { + fn from(value: &SystemMetricName) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for SystemMetricName { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::VirtualDiskSpaceProvisioned => f.write_str("virtual_disk_space_provisioned"), + Self::CpusProvisioned => f.write_str("cpus_provisioned"), + Self::RamProvisioned => f.write_str("ram_provisioned"), + } + } + } + + impl ::std::str::FromStr for SystemMetricName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), + "cpus_provisioned" => Ok(Self::CpusProvisioned), + "ram_provisioned" => Ok(Self::RamProvisioned), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for SystemMetricName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdate { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdate> for SystemUpdate { + fn from(value: &SystemUpdate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/SystemUpdate" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdateResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&SystemUpdateResultsPage> for SystemUpdateResultsPage { + fn from(value: &SystemUpdateResultsPage) -> Self { + value.clone() + } + } + + ///`SystemUpdateStart` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "version" + /// ], + /// "properties": { + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemUpdateStart { + pub version: SemverVersion, + } + + impl ::std::convert::From<&SystemUpdateStart> for SystemUpdateStart { + fn from(value: &SystemUpdateStart) -> Self { + value.clone() + } + } + + ///`SystemVersion` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "status", + /// "version_range" + /// ], + /// "properties": { + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "version_range": { + /// "$ref": "#/components/schemas/VersionRange" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct SystemVersion { + pub status: UpdateStatus, + pub version_range: VersionRange, + } + + impl ::std::convert::From<&SystemVersion> for SystemVersion { + fn from(value: &SystemVersion) -> Self { + value.clone() + } + } + + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "The name of a timeseries", + /// "description": "Names are constructed by concatenating the target and + /// metric names with ':'. Target and metric names must be lowercase + /// alphanumeric characters with '_' separating words.", + /// "type": "string", + /// "pattern": + /// "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct TimeseriesName(::std::string::String); + impl ::std::ops::Deref for TimeseriesName { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: TimeseriesName) -> Self { + value.0 + } + } + + impl ::std::convert::From<&TimeseriesName> for TimeseriesName { + fn from(value: &TimeseriesName) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for TimeseriesName { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = + ::std::sync::LazyLock::new(|| { + ::regress::Regex::new( + "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", + ) + .unwrap() + }); + if PATTERN.find(value).is_none() { + return Err("doesn't match pattern \ + \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ + )(_([a-z0-9]+))*)\"" + .into()); + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for TimeseriesName { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for TimeseriesName { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///The schema for a timeseries. + /// + ///This includes the name of the timeseries, as well as the datum type of + /// its metric and the schema for each field. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The schema for a timeseries.\n\nThis includes the name + /// of the timeseries, as well as the datum type of its metric and the + /// schema for each field.", + /// "type": "object", + /// "required": [ + /// "created", + /// "datum_type", + /// "field_schema", + /// "timeseries_name" + /// ], + /// "properties": { + /// "created": { + /// "type": "string", + /// "format": "date-time" + /// }, + /// "datum_type": { + /// "$ref": "#/components/schemas/DatumType" + /// }, + /// "field_schema": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/FieldSchema" + /// } + /// }, + /// "timeseries_name": { + /// "$ref": "#/components/schemas/TimeseriesName" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TimeseriesSchema { + pub created: ::chrono::DateTime<::chrono::offset::Utc>, + pub datum_type: DatumType, + pub field_schema: ::std::vec::Vec, + pub timeseries_name: TimeseriesName, + } + + impl ::std::convert::From<&TimeseriesSchema> for TimeseriesSchema { + fn from(value: &TimeseriesSchema) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/TimeseriesSchema" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct TimeseriesSchemaResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&TimeseriesSchemaResultsPage> for TimeseriesSchemaResultsPage { + fn from(value: &TimeseriesSchemaResultsPage) -> Self { + value.clone() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "id", + /// "status", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateDeployment { + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateDeployment> for UpdateDeployment { + fn from(value: &UpdateDeployment) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateDeployment" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateDeploymentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateDeploymentResultsPage> for UpdateDeploymentResultsPage { + fn from(value: &UpdateDeploymentResultsPage) -> Self { + value.clone() + } + } + + ///`UpdateStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "updating" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "status" + /// ], + /// "properties": { + /// "status": { + /// "type": "string", + /// "enum": [ + /// "steady" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + #[serde(tag = "status")] + pub enum UpdateStatus { + #[serde(rename = "updating")] + Updating, + #[serde(rename = "steady")] + Steady, + } + + impl ::std::convert::From<&Self> for UpdateStatus { + fn from(value: &UpdateStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Updating => f.write_str("updating"), + Self::Steady => f.write_str("steady"), + } + } + } + + impl ::std::str::FromStr for UpdateStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "updating" => Ok(Self::Updating), + "steady" => Ok(Self::Steady), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Identity-related metadata that's included in "asset" public API objects + /// (which generally have no name or description) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Identity-related metadata that's included in \"asset\" + /// public API objects (which generally have no name or description)", + /// "type": "object", + /// "required": [ + /// "component_type", + /// "device_id", + /// "id", + /// "status", + /// "system_version", + /// "time_created", + /// "time_modified", + /// "version" + /// ], + /// "properties": { + /// "component_type": { + /// "$ref": "#/components/schemas/UpdateableComponentType" + /// }, + /// "device_id": { + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "status": { + /// "$ref": "#/components/schemas/UpdateStatus" + /// }, + /// "system_version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "version": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateableComponent { + pub component_type: UpdateableComponentType, + pub device_id: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub status: UpdateStatus, + pub system_version: SemverVersion, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + pub version: SemverVersion, + } + + impl ::std::convert::From<&UpdateableComponent> for UpdateableComponent { + fn from(value: &UpdateableComponent) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UpdateableComponent" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UpdateableComponentResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UpdateableComponentResultsPage> for UpdateableComponentResultsPage { + fn from(value: &UpdateableComponentResultsPage) -> Self { + value.clone() + } + } + + ///`UpdateableComponentType` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "bootloader_for_rot", + /// "bootloader_for_sp", + /// "bootloader_for_host_proc", + /// "hubris_for_psc_rot", + /// "hubris_for_psc_sp", + /// "hubris_for_sidecar_rot", + /// "hubris_for_sidecar_sp", + /// "hubris_for_gimlet_rot", + /// "hubris_for_gimlet_sp", + /// "helios_host_phase1", + /// "helios_host_phase2", + /// "host_omicron" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum UpdateableComponentType { + #[serde(rename = "bootloader_for_rot")] + BootloaderForRot, + #[serde(rename = "bootloader_for_sp")] + BootloaderForSp, + #[serde(rename = "bootloader_for_host_proc")] + BootloaderForHostProc, + #[serde(rename = "hubris_for_psc_rot")] + HubrisForPscRot, + #[serde(rename = "hubris_for_psc_sp")] + HubrisForPscSp, + #[serde(rename = "hubris_for_sidecar_rot")] + HubrisForSidecarRot, + #[serde(rename = "hubris_for_sidecar_sp")] + HubrisForSidecarSp, + #[serde(rename = "hubris_for_gimlet_rot")] + HubrisForGimletRot, + #[serde(rename = "hubris_for_gimlet_sp")] + HubrisForGimletSp, + #[serde(rename = "helios_host_phase1")] + HeliosHostPhase1, + #[serde(rename = "helios_host_phase2")] + HeliosHostPhase2, + #[serde(rename = "host_omicron")] + HostOmicron, + } + + impl ::std::convert::From<&Self> for UpdateableComponentType { + fn from(value: &UpdateableComponentType) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for UpdateableComponentType { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::BootloaderForRot => f.write_str("bootloader_for_rot"), + Self::BootloaderForSp => f.write_str("bootloader_for_sp"), + Self::BootloaderForHostProc => f.write_str("bootloader_for_host_proc"), + Self::HubrisForPscRot => f.write_str("hubris_for_psc_rot"), + Self::HubrisForPscSp => f.write_str("hubris_for_psc_sp"), + Self::HubrisForSidecarRot => f.write_str("hubris_for_sidecar_rot"), + Self::HubrisForSidecarSp => f.write_str("hubris_for_sidecar_sp"), + Self::HubrisForGimletRot => f.write_str("hubris_for_gimlet_rot"), + Self::HubrisForGimletSp => f.write_str("hubris_for_gimlet_sp"), + Self::HeliosHostPhase1 => f.write_str("helios_host_phase1"), + Self::HeliosHostPhase2 => f.write_str("helios_host_phase2"), + Self::HostOmicron => f.write_str("host_omicron"), + } + } + } + + impl ::std::str::FromStr for UpdateableComponentType { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "bootloader_for_rot" => Ok(Self::BootloaderForRot), + "bootloader_for_sp" => Ok(Self::BootloaderForSp), + "bootloader_for_host_proc" => Ok(Self::BootloaderForHostProc), + "hubris_for_psc_rot" => Ok(Self::HubrisForPscRot), + "hubris_for_psc_sp" => Ok(Self::HubrisForPscSp), + "hubris_for_sidecar_rot" => Ok(Self::HubrisForSidecarRot), + "hubris_for_sidecar_sp" => Ok(Self::HubrisForSidecarSp), + "hubris_for_gimlet_rot" => Ok(Self::HubrisForGimletRot), + "hubris_for_gimlet_sp" => Ok(Self::HubrisForGimletSp), + "helios_host_phase1" => Ok(Self::HeliosHostPhase1), + "helios_host_phase2" => Ok(Self::HeliosHostPhase2), + "host_omicron" => Ok(Self::HostOmicron), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UpdateableComponentType { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Client view of a [`User`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`User`]", + /// "type": "object", + /// "required": [ + /// "display_name", + /// "id", + /// "silo_id" + /// ], + /// "properties": { + /// "display_name": { + /// "description": "Human-readable name that can identify the user", + /// "type": "string" + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "silo_id": { + /// "description": "Uuid of the silo to which this user belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct User { + ///Human-readable name that can identify the user + pub display_name: ::std::string::String, + pub id: ::uuid::Uuid, + ///Uuid of the silo to which this user belongs + pub silo_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&User> for User { + fn from(value: &User) -> Self { + value.clone() + } + } + + ///Client view of a [`UserBuiltin`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`UserBuiltin`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "name", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserBuiltin { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&UserBuiltin> for UserBuiltin { + fn from(value: &UserBuiltin) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/UserBuiltin" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserBuiltinResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserBuiltinResultsPage> for UserBuiltinResultsPage { + fn from(value: &UserBuiltinResultsPage) -> Self { + value.clone() + } + } + + ///Create-time parameters for a [`User`](crate::external_api::views::User) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`User`](crate::external_api::views::User)", + /// "type": "object", + /// "required": [ + /// "external_id", + /// "password" + /// ], + /// "properties": { + /// "external_id": { + /// "description": "username used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserId" + /// } + /// ] + /// }, + /// "password": { + /// "description": "password used to log in", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/UserPassword" + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserCreate { + ///username used to log in + pub external_id: UserId, + ///password used to log in + pub password: UserPassword, + } + + impl ::std::convert::From<&UserCreate> for UserCreate { + fn from(value: &UserCreate) -> Self { + value.clone() + } + } + + ///Names must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. Names cannot be a UUID though they may contain a UUID. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "title": "A name unique within the parent collection", + /// "description": "Names must begin with a lower case ASCII letter, be + /// composed exclusively of lowercase ASCII, uppercase ASCII, numbers, and + /// '-', and may not end with a '-'. Names cannot be a UUID though they may + /// contain a UUID.", + /// "type": "string", + /// "maxLength": 63, + /// "pattern": + /// "^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]* + /// [a-zA-Z0-9]$" + ///} + /// ``` + ///
+ #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[serde(transparent)] + pub struct UserId(::std::string::String); + impl ::std::ops::Deref for UserId { + type Target = ::std::string::String; + fn deref(&self) -> &::std::string::String { + &self.0 + } + } + + impl ::std::convert::From for ::std::string::String { + fn from(value: UserId) -> Self { + value.0 + } + } + + impl ::std::convert::From<&UserId> for UserId { + fn from(value: &UserId) -> Self { + value.clone() + } + } + + impl ::std::str::FromStr for UserId { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + if value.chars().count() > 63usize { + return Err("longer than 63 characters".into()); + } + static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new( + || { + :: regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () + }, + ); + if PATTERN.find(value).is_none() { + return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; + } + Ok(Self(value.to_string())) + } + } + + impl ::std::convert::TryFrom<&str> for UserId { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for UserId { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl<'de> ::serde::Deserialize<'de> for UserId { + fn deserialize(deserializer: D) -> ::std::result::Result + where + D: ::serde::Deserializer<'de>, + { + ::std::string::String::deserialize(deserializer)? + .parse() + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) + } + } + + ///Parameters for setting a user's password + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Parameters for setting a user's password", + /// "oneOf": [ + /// { + /// "description": "Sets the user's password to the provided value", + /// "type": "object", + /// "required": [ + /// "details", + /// "user_password_value" + /// ], + /// "properties": { + /// "details": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "password" + /// ] + /// } + /// } + /// }, + /// { + /// "description": "Invalidates any current password (disabling + /// password authentication)", + /// "type": "object", + /// "required": [ + /// "user_password_value" + /// ], + /// "properties": { + /// "user_password_value": { + /// "type": "string", + /// "enum": [ + /// "invalid_password" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "user_password_value", content = "details")] + pub enum UserPassword { + ///Sets the user's password to the provided value + #[serde(rename = "password")] + Password(Password), + #[serde(rename = "invalid_password")] + InvalidPassword, + } + + impl ::std::convert::From<&Self> for UserPassword { + fn from(value: &UserPassword) -> Self { + value.clone() + } + } + + impl ::std::convert::From for UserPassword { + fn from(value: Password) -> Self { + Self::Password(value) + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/User" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UserResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&UserResultsPage> for UserResultsPage { + fn from(value: &UserResultsPage) -> Self { + value.clone() + } + } + + ///Credentials for local user login + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Credentials for local user login", + /// "type": "object", + /// "required": [ + /// "password", + /// "username" + /// ], + /// "properties": { + /// "password": { + /// "$ref": "#/components/schemas/Password" + /// }, + /// "username": { + /// "$ref": "#/components/schemas/UserId" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct UsernamePasswordCredentials { + pub password: Password, + pub username: UserId, + } + + impl ::std::convert::From<&UsernamePasswordCredentials> for UsernamePasswordCredentials { + fn from(value: &UsernamePasswordCredentials) -> Self { + value.clone() + } + } + + ///`VersionRange` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "high", + /// "low" + /// ], + /// "properties": { + /// "high": { + /// "$ref": "#/components/schemas/SemverVersion" + /// }, + /// "low": { + /// "$ref": "#/components/schemas/SemverVersion" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VersionRange { + pub high: SemverVersion, + pub low: SemverVersion, + } + + impl ::std::convert::From<&VersionRange> for VersionRange { + fn from(value: &VersionRange) -> Self { + value.clone() + } + } + + ///Client view of a [`Vpc`] + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Client view of a [`Vpc`]", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "id", + /// "ipv6_prefix", + /// "name", + /// "project_id", + /// "system_router_id", + /// "time_created", + /// "time_modified" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "dns_name": { + /// "description": "The name used for the VPC in DNS.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv6_prefix": { + /// "description": "The unique local IPv6 address range for subnets in + /// this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "project_id": { + /// "description": "id for the project containing this VPC", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "system_router_id": { + /// "description": "id for the system router where subnet default + /// routes are registered", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Vpc { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///The name used for the VPC in DNS. + pub dns_name: Name, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The unique local IPv6 address range for subnets in this VPC + pub ipv6_prefix: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///id for the project containing this VPC + pub project_id: ::uuid::Uuid, + ///id for the system router where subnet default routes are registered + pub system_router_id: ::uuid::Uuid, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + } + + impl ::std::convert::From<&Vpc> for Vpc { + fn from(value: &Vpc) -> Self { + value.clone() + } + } + + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "required": [ + /// "description", + /// "dns_name", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "dns_name": { + /// "$ref": "#/components/schemas/Name" + /// }, + /// "ipv6_prefix": { + /// "description": "The IPv6 prefix for this VPC.\n\nAll IPv6 subnets + /// created from this VPC must be taken from this range, which sould be a + /// Unique Local Address in the range `fd00::/48`. The default VPC Subnet + /// will have the first `/64` range from this prefix.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcCreate { + pub description: ::std::string::String, + pub dns_name: Name, + ///The IPv6 prefix for this VPC. + /// + ///All IPv6 subnets created from this VPC must be taken from this + /// range, which sould be a Unique Local Address in the range + /// `fd00::/48`. The default VPC Subnet will have the first `/64` range + /// from this prefix. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_prefix: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcCreate> for VpcCreate { + fn from(value: &VpcCreate) -> Self { + value.clone() + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "id", + /// "name", + /// "priority", + /// "status", + /// "targets", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "the VPC to which this rule belongs", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRule { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///the VPC to which this rule belongs + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcFirewallRule> for VpcFirewallRule { + fn from(value: &VpcFirewallRule) -> Self { + value.clone() + } + } + + ///`VpcFirewallRuleAction` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "allow", + /// "deny" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleAction { + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleAction { + fn from(value: &VpcFirewallRuleAction) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleAction { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Allow => f.write_str("allow"), + Self::Deny => f.write_str("deny"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleAction { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "allow" => Ok(Self::Allow), + "deny" => Ok(Self::Deny), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleAction { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleDirection` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "inbound", + /// "outbound" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleDirection { + #[serde(rename = "inbound")] + Inbound, + #[serde(rename = "outbound")] + Outbound, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleDirection { + fn from(value: &VpcFirewallRuleDirection) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleDirection { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Inbound => f.write_str("inbound"), + Self::Outbound => f.write_str("outbound"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleDirection { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "inbound" => Ok(Self::Inbound), + "outbound" => Ok(Self::Outbound), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleDirection { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///Filter for a firewall rule. A given packet must match every field that + /// is present for the rule to apply to it. A packet matches a field if any + /// entry in that field matches the packet. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Filter for a firewall rule. A given packet must match + /// every field that is present for the rule to apply to it. A packet + /// matches a field if any entry in that field matches the packet.", + /// "type": "object", + /// "properties": { + /// "hosts": { + /// "description": "If present, the sources (if incoming) or + /// destinations (if outgoing) this rule applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleHostFilter" + /// } + /// }, + /// "ports": { + /// "description": "If present, the destination ports this rule applies + /// to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/L4PortRange" + /// } + /// }, + /// "protocols": { + /// "description": "If present, the networking protocols this rule + /// applies to.", + /// "type": [ + /// "array", + /// "null" + /// ], + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleProtocol" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleFilter { + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub hosts: ::std::option::Option<::std::vec::Vec>, + ///If present, the destination ports this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ports: ::std::option::Option<::std::vec::Vec>, + ///If present, the networking protocols this rule applies to. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub protocols: ::std::option::Option<::std::vec::Vec>, + } + + impl ::std::convert::From<&VpcFirewallRuleFilter> for VpcFirewallRuleFilter { + fn from(value: &VpcFirewallRuleFilter) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcFirewallRuleFilter { + fn default() -> Self { + Self { + hosts: Default::default(), + ports: Default::default(), + protocols: Default::default(), + } + } + } + + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The `VpcFirewallRuleHostFilter` is used to filter + /// traffic on the basis of its source or destination host.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to all instances + /// in the VPC Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to this specific + /// instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to traffic from/to a specific IP + /// subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleHostFilter { + ///The rule applies to traffic from/to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to traffic from/to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to traffic from/to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to traffic from/to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to traffic from/to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleHostFilter { + fn from(value: &VpcFirewallRuleHostFilter) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleHostFilter { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleHostFilter { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///The protocols that may be specified in a firewall rule's filter + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "The protocols that may be specified in a firewall + /// rule's filter", + /// "type": "string", + /// "enum": [ + /// "TCP", + /// "UDP", + /// "ICMP" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleProtocol { + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, + #[serde(rename = "ICMP")] + Icmp, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleProtocol { + fn from(value: &VpcFirewallRuleProtocol) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleProtocol { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Tcp => f.write_str("TCP"), + Self::Udp => f.write_str("UDP"), + Self::Icmp => f.write_str("ICMP"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleProtocol { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "TCP" => Ok(Self::Tcp), + "UDP" => Ok(Self::Udp), + "ICMP" => Ok(Self::Icmp), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleProtocol { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`VpcFirewallRuleStatus` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "disabled", + /// "enabled" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcFirewallRuleStatus { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleStatus { + fn from(value: &VpcFirewallRuleStatus) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcFirewallRuleStatus { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Disabled => f.write_str("disabled"), + Self::Enabled => f.write_str("enabled"), + } + } + } + + impl ::std::str::FromStr for VpcFirewallRuleStatus { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "disabled" => Ok(Self::Disabled), + "enabled" => Ok(Self::Enabled), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcFirewallRuleStatus { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A `VpcFirewallRuleTarget` is used to specify the set of + /// [`Instance`]s to which a firewall rule applies.", + /// "oneOf": [ + /// { + /// "description": "The rule applies to all instances in the VPC", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "vpc" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to all instances in the VPC + /// Subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "subnet" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to this specific instance", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "instance" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP address", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip" + /// ] + /// }, + /// "value": { + /// "type": "string", + /// "format": "ip" + /// } + /// } + /// }, + /// { + /// "description": "The rule applies to a specific IP subnet", + /// "type": "object", + /// "required": [ + /// "type", + /// "value" + /// ], + /// "properties": { + /// "type": { + /// "type": "string", + /// "enum": [ + /// "ip_net" + /// ] + /// }, + /// "value": { + /// "$ref": "#/components/schemas/IpNet" + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type", content = "value")] + pub enum VpcFirewallRuleTarget { + ///The rule applies to all instances in the VPC + #[serde(rename = "vpc")] + Vpc(Name), + ///The rule applies to all instances in the VPC Subnet + #[serde(rename = "subnet")] + Subnet(Name), + ///The rule applies to this specific instance + #[serde(rename = "instance")] + Instance(Name), + ///The rule applies to a specific IP address + #[serde(rename = "ip")] + Ip(::std::net::IpAddr), + ///The rule applies to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + impl ::std::convert::From<&Self> for VpcFirewallRuleTarget { + fn from(value: &VpcFirewallRuleTarget) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::std::net::IpAddr> for VpcFirewallRuleTarget { + fn from(value: ::std::net::IpAddr) -> Self { + Self::Ip(value) + } + } + + impl ::std::convert::From for VpcFirewallRuleTarget { + fn from(value: IpNet) -> Self { + Self::IpNet(value) + } + } + + ///A single rule in a VPC firewall + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single rule in a VPC firewall", + /// "type": "object", + /// "required": [ + /// "action", + /// "description", + /// "direction", + /// "filters", + /// "name", + /// "priority", + /// "status", + /// "targets" + /// ], + /// "properties": { + /// "action": { + /// "description": "whether traffic matching the rule should be allowed + /// or dropped", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleAction" + /// } + /// ] + /// }, + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "direction": { + /// "description": "whether this rule is for incoming or outgoing + /// traffic", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleDirection" + /// } + /// ] + /// }, + /// "filters": { + /// "description": "reductions on the scope of the rule", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleFilter" + /// } + /// ] + /// }, + /// "name": { + /// "description": "name of the rule, unique to this VPC", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "priority": { + /// "description": "the relative priority of this rule", + /// "type": "integer", + /// "format": "uint16", + /// "minimum": 0.0 + /// }, + /// "status": { + /// "description": "whether this rule is in effect", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/VpcFirewallRuleStatus" + /// } + /// ] + /// }, + /// "targets": { + /// "description": "list of sets of instances that the rule applies + /// to", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleTarget" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleUpdate { + ///whether traffic matching the rule should be allowed or dropped + pub action: VpcFirewallRuleAction, + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///whether this rule is for incoming or outgoing traffic + pub direction: VpcFirewallRuleDirection, + ///reductions on the scope of the rule + pub filters: VpcFirewallRuleFilter, + ///name of the rule, unique to this VPC + pub name: Name, + ///the relative priority of this rule + pub priority: u16, + ///whether this rule is in effect + pub status: VpcFirewallRuleStatus, + ///list of sets of instances that the rule applies to + pub targets: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdate> for VpcFirewallRuleUpdate { + fn from(value: &VpcFirewallRuleUpdate) -> Self { + value.clone() + } + } + + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a `Vpc`'s firewall Note that + /// VpcFirewallRules are implicitly created along with a Vpc, so there is no + /// explicit creation.", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRuleUpdate" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRuleUpdateParams { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRuleUpdateParams> for VpcFirewallRuleUpdateParams { + fn from(value: &VpcFirewallRuleUpdateParams) -> Self { + value.clone() + } + } + + ///Collection of a Vpc's firewall rules + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Collection of a Vpc's firewall rules", + /// "type": "object", + /// "required": [ + /// "rules" + /// ], + /// "properties": { + /// "rules": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcFirewallRule" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcFirewallRules { + pub rules: ::std::vec::Vec, + } + + impl ::std::convert::From<&VpcFirewallRules> for VpcFirewallRules { + fn from(value: &VpcFirewallRules) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/Vpc" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcResultsPage> for VpcResultsPage { + fn from(value: &VpcResultsPage) -> Self { + value.clone() + } + } + + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC router defines a series of rules that indicate + /// where traffic should be sent depending on its destination.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "kind", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "kind": { + /// "$ref": "#/components/schemas/VpcRouterKind" + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the router belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouter { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + pub kind: VpcRouterKind, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the router belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcRouter> for VpcRouter { + fn from(value: &VpcRouter) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "required": [ + /// "description", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterCreate { + pub description: ::std::string::String, + pub name: Name, + } + + impl ::std::convert::From<&VpcRouterCreate> for VpcRouterCreate { + fn from(value: &VpcRouterCreate) -> Self { + value.clone() + } + } + + ///`VpcRouterKind` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "system", + /// "custom" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum VpcRouterKind { + #[serde(rename = "system")] + System, + #[serde(rename = "custom")] + Custom, + } + + impl ::std::convert::From<&Self> for VpcRouterKind { + fn from(value: &VpcRouterKind) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for VpcRouterKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::System => f.write_str("system"), + Self::Custom => f.write_str("custom"), + } + } + } + + impl ::std::str::FromStr for VpcRouterKind { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "system" => Ok(Self::System), + "custom" => Ok(Self::Custom), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for VpcRouterKind { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcRouter" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcRouterResultsPage> for VpcRouterResultsPage { + fn from(value: &VpcRouterResultsPage) -> Self { + value.clone() + } + } + + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcRouterUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcRouterUpdate> for VpcRouterUpdate { + fn from(value: &VpcRouterUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcRouterUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A VPC subnet represents a logical grouping for + /// instances that allows network traffic between them, within a IPv4 + /// subnetwork or optionall an IPv6 subnetwork.", + /// "type": "object", + /// "required": [ + /// "description", + /// "id", + /// "ipv4_block", + /// "ipv6_block", + /// "name", + /// "time_created", + /// "time_modified", + /// "vpc_id" + /// ], + /// "properties": { + /// "description": { + /// "description": "human-readable free-form text about a resource", + /// "type": "string" + /// }, + /// "id": { + /// "description": "unique, immutable, system-controlled identifier for + /// each resource", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 subnet CIDR block.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// }, + /// "name": { + /// "description": "unique, mutable, user-controlled identifier for + /// each resource", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// }, + /// "time_created": { + /// "description": "timestamp when this resource was created", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "time_modified": { + /// "description": "timestamp when this resource was last modified", + /// "type": "string", + /// "format": "date-time" + /// }, + /// "vpc_id": { + /// "description": "The VPC to which the subnet belongs.", + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnet { + ///human-readable free-form text about a resource + pub description: ::std::string::String, + ///unique, immutable, system-controlled identifier for each resource + pub id: ::uuid::Uuid, + ///The IPv4 subnet CIDR block. + pub ipv4_block: Ipv4Net, + ///The IPv6 subnet CIDR block. + pub ipv6_block: Ipv6Net, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: ::chrono::DateTime<::chrono::offset::Utc>, + ///timestamp when this resource was last modified + pub time_modified: ::chrono::DateTime<::chrono::offset::Utc>, + ///The VPC to which the subnet belongs. + pub vpc_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&VpcSubnet> for VpcSubnet { + fn from(value: &VpcSubnet) -> Self { + value.clone() + } + } + + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "required": [ + /// "description", + /// "ipv4_block", + /// "name" + /// ], + /// "properties": { + /// "description": { + /// "type": "string" + /// }, + /// "ipv4_block": { + /// "description": "The IPv4 address range for this subnet.\n\nIt must + /// be allocated from an RFC 1918 private address range, and must not + /// overlap with any other existing subnet in the VPC.", + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv4Net" + /// } + /// ] + /// }, + /// "ipv6_block": { + /// "description": "The IPv6 address range for this subnet.\n\nIt must + /// be allocated from the RFC 4193 Unique Local Address range, with the + /// prefix equal to the parent VPC's prefix. A random `/64` block will be + /// assigned if one is not provided. It must not overlap with any existing + /// subnet in the VPC.", + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Ipv6Net" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "$ref": "#/components/schemas/Name" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetCreate { + pub description: ::std::string::String, + ///The IPv4 address range for this subnet. + /// + ///It must be allocated from an RFC 1918 private address range, and + /// must not overlap with any other existing subnet in the VPC. + pub ipv4_block: Ipv4Net, + ///The IPv6 address range for this subnet. + /// + ///It must be allocated from the RFC 4193 Unique Local Address range, + /// with the prefix equal to the parent VPC's prefix. A random `/64` + /// block will be assigned if one is not provided. It must not overlap + /// with any existing subnet in the VPC. + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub ipv6_block: ::std::option::Option, + pub name: Name, + } + + impl ::std::convert::From<&VpcSubnetCreate> for VpcSubnetCreate { + fn from(value: &VpcSubnetCreate) -> Self { + value.clone() + } + } + + ///A single page of results + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A single page of results", + /// "type": "object", + /// "required": [ + /// "items" + /// ], + /// "properties": { + /// "items": { + /// "description": "list of items on this page of results", + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VpcSubnet" + /// } + /// }, + /// "next_page": { + /// "description": "token used to fetch the next page of results (if + /// any)", + /// "type": [ + /// "string", + /// "null" + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetResultsPage { + ///list of items on this page of results + pub items: ::std::vec::Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub next_page: ::std::option::Option<::std::string::String>, + } + + impl ::std::convert::From<&VpcSubnetResultsPage> for VpcSubnetResultsPage { + fn from(value: &VpcSubnetResultsPage) -> Self { + value.clone() + } + } + + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcSubnetUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcSubnetUpdate> for VpcSubnetUpdate { + fn from(value: &VpcSubnetUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcSubnetUpdate { + fn default() -> Self { + Self { + description: Default::default(), + name: Default::default(), + } + } + } + + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Updateable properties of a + /// [`Vpc`](crate::external_api::views::Vpc)", + /// "type": "object", + /// "properties": { + /// "description": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "dns_name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// }, + /// "name": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/Name" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct VpcUpdate { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub description: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub dns_name: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub name: ::std::option::Option, + } + + impl ::std::convert::From<&VpcUpdate> for VpcUpdate { + fn from(value: &VpcUpdate) -> Self { + value.clone() + } + } + + impl ::std::default::Default for VpcUpdate { + fn default() -> Self { + Self { + description: Default::default(), + dns_name: Default::default(), + name: Default::default(), + } + } + } + + /// Generation of default values for serde. + pub mod defaults { + pub(super) fn default_bool() -> bool { + V + } + + pub(super) fn instance_create_network_interfaces( + ) -> super::InstanceNetworkInterfaceAttachment { + super::InstanceNetworkInterfaceAttachment::Default + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Region API +/// +///API for interacting with the Oxide control plane +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Fetch a disk by id + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to `/by-id/disks/{id}` + pub async fn disk_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/disks/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an image by id + /// + ///Sends a `GET` request to `/by-id/images/{id}` + pub async fn image_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/images/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance by id + /// + ///Sends a `GET` request to `/by-id/instances/{id}` + pub async fn instance_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/instances/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a network interface by id + /// + ///Sends a `GET` request to `/by-id/network-interfaces/{id}` + pub async fn instance_network_interface_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/network-interfaces/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization by id + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/by-id/organizations/{id}` + pub async fn organization_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/organizations/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project by id + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to `/by-id/projects/{id}` + pub async fn project_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/projects/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a snapshot by id + /// + ///Sends a `GET` request to `/by-id/snapshots/{id}` + pub async fn snapshot_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/snapshots/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a route by id + /// + ///Sends a `GET` request to `/by-id/vpc-router-routes/{id}` + pub async fn vpc_router_route_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/vpc-router-routes/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Get a router by id + /// + ///Sends a `GET` request to `/by-id/vpc-routers/{id}` + pub async fn vpc_router_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/vpc-routers/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a subnet by id + /// + ///Sends a `GET` request to `/by-id/vpc-subnets/{id}` + pub async fn vpc_subnet_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/vpc-subnets/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a VPC + /// + ///Sends a `GET` request to `/by-id/vpcs/{id}` + pub async fn vpc_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/by-id/vpcs/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Start an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed from an *unauthenticated* API + /// client. It generates and records a `device_code` and `user_code` which + /// must be verified and confirmed prior to a token being granted. + /// + ///Sends a `POST` request to `/device/auth` + pub async fn device_auth_request<'a>( + &'a self, + body: &'a types::DeviceAuthRequest, + ) -> Result, Error> { + let url = format!("{}/device/auth", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_auth_request", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + + ///Confirm an OAuth 2.0 Device Authorization Grant + /// + ///This endpoint is designed to be accessed by the user agent (browser), + /// not the client requesting the token. So we do not actually return the + /// token here; it will be returned in response to the poll on + /// `/device/token`. + /// + ///Sends a `POST` request to `/device/confirm` + pub async fn device_auth_confirm<'a>( + &'a self, + body: &'a types::DeviceAuthVerify, + ) -> Result, Error> { + let url = format!("{}/device/confirm", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "device_auth_confirm", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Request a device access token + /// + ///This endpoint should be polled by the client until the user code is + /// verified and the grant is confirmed. + /// + ///Sends a `POST` request to `/device/token` + pub async fn device_access_token<'a>( + &'a self, + body: &'a types::DeviceAccessTokenRequest, + ) -> Result, Error> { + let url = format!("{}/device/token", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .header("content-type", "application/x-www-form-urlencoded") + .body( + ::serde_urlencoded::to_string(&body) + .map_err(|e| Error::InvalidRequest(e.to_string()))?, + )?; + let info = OperationInfo { + operation_id: "device_access_token", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + + ///List groups + /// + ///Sends a `GET` request to `/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn group_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/groups", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "group_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List groups as a Stream + /// + ///Sends repeated `GET` requests to `/groups` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn group_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.group_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.group_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Sends a `POST` request to `/login` + pub async fn login_spoof<'a>( + &'a self, + body: &'a types::SpoofLoginBody, + ) -> Result, Error> { + let url = format!("{}/login", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_spoof", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Authenticate a user (i.e., log in) via username and password + /// + ///Sends a `POST` request to `/login/{silo_name}/local` + pub async fn login_local<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::UsernamePasswordCredentials, + ) -> Result, Error> { + let url = format!( + "{}/login/{}/local", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "login_local", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Prompt user login + /// + ///Either display a page asking a user for their credentials, or redirect + /// them to their identity provider. + /// + ///Sends a `GET` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn login_saml_begin<'a>( + &'a self, + silo_name: &'a types::Name, + provider_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/login/{}/saml/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "login_saml_begin", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Authenticate a user (i.e., log in) via SAML + /// + ///Sends a `POST` request to `/login/{silo_name}/saml/{provider_name}` + pub async fn login_saml<'a, B: Into<::wasm_bindgen::JsValue>>( + &'a self, + silo_name: &'a types::Name, + provider_name: &'a types::Name, + body: B, + ) -> Result, Error> { + let url = format!( + "{}/login/{}/saml/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("api-version", Self::api_version()) + .header("content-type", "application/octet-stream") + .body(body)?; + let info = OperationInfo { + operation_id: "login_saml", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200..=299 => Ok(ResponseValue::stream(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `POST` request to `/logout` + pub async fn logout<'a>(&'a self) -> Result, Error> { + let url = format!("{}/logout", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "logout", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations + /// + ///Use `GET /v1/organizations` instead + /// + ///Sends a `GET` request to `/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn organization_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/organizations", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations as a Stream + /// + ///Use `GET /v1/organizations` instead + /// + ///Sends repeated `GET` requests to `/organizations` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn organization_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.organization_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.organization_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an organization + /// + ///Use `POST /v1/organizations` instead + /// + ///Sends a `POST` request to `/organizations` + pub async fn organization_create<'a>( + &'a self, + body: &'a types::OrganizationCreate, + ) -> Result, Error> { + let url = format!("{}/organizations", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization + /// + ///Use `GET /v1/organizations/{organization}` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + pub async fn organization_view<'a>( + &'a self, + organization_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization + /// + ///Use `PUT /v1/organizations/{organization}` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + pub async fn organization_update<'a>( + &'a self, + organization_name: &'a types::Name, + body: &'a types::OrganizationUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an organization + /// + ///Use `DELETE /v1/organizations/{organization}` instead + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + pub async fn organization_delete<'a>( + &'a self, + organization_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization's IAM policy + /// + ///Use `GET /v1/organizations/{organization}/policy` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + pub async fn organization_policy_view<'a>( + &'a self, + organization_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/policy", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization's IAM policy + /// + ///Use `PUT /v1/organizations/{organization}/policy` instead + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + pub async fn organization_policy_update<'a>( + &'a self, + organization_name: &'a types::Name, + body: &'a types::OrganizationRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/policy", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects + /// + ///Use `GET /v1/projects` instead + /// + ///Sends a `GET` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn project_list<'a>( + &'a self, + organization_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects as a Stream + /// + ///Use `GET /v1/projects` instead + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects` until there are no more + /// results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn project_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.project_list(organization_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.project_list(organization_name, limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a project + /// + ///Use `POST /v1/projects` instead + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + pub async fn project_create<'a>( + &'a self, + organization_name: &'a types::Name, + body: &'a types::ProjectCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects", + self.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project + /// + ///Use `GET /v1/projects/{project}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + pub async fn project_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project + /// + ///Use `PUT /v1/projects/{project}` instead + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn project_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::ProjectUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a project + /// + ///Use `DELETE /v1/projects/{project}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + pub async fn project_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List disks + /// + ///Use `GET /v1/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn disk_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/disks", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List disks as a Stream + /// + ///Use `GET /v1/disks` instead + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks` until + /// there are no more results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn disk_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.disk_list(organization_name, project_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.disk_list( + organization_name, + project_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Use `POST /v1/disks` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn disk_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::DiskCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/disks", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a disk + /// + ///Use `GET /v1/disks/{disk}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn disk_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + disk_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Use `DELETE /v1/disks/{disk}` instead + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` + pub async fn disk_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + disk_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch disk metrics + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `disk_name` + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + pub async fn disk_metrics_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + disk_name: &'a types::Name, + metric_name: types::DiskMetricName, + end_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + start_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/disks/{}/metrics/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_metrics_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch disk metrics as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}/metrics/{metric_name}` until there are no more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `disk_name` + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `limit`: Maximum number of items returned by a single call + /// - `start_time`: An inclusive start time of metrics. + pub fn disk_metrics_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + disk_name: &'a types::Name, + metric_name: types::DiskMetricName, + end_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + limit: Option<::std::num::NonZeroU32>, + start_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.disk_metrics_list( + organization_name, + project_name, + disk_name, + metric_name, + end_time, + limit, + None, + start_time, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.disk_metrics_list( + organization_name, + project_name, + disk_name, + metric_name, + None, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List images + /// + ///List images in a project. The images are returned sorted by creation + /// date, with the most recent images appearing first. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn image_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/images", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List images as a Stream + /// + ///List images in a project. The images are returned sorted by creation + /// date, with the most recent images appearing first. + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// until there are no more results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn image_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.image_list(organization_name, project_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.image_list( + organization_name, + project_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an image + /// + ///Create a new image in a project. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/images` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn image_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::ImageCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/images", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "image_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an image + /// + ///Fetch the details for a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn image_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an image + /// + ///Permanently delete an image from a project. This operation cannot be + /// undone. Any instances in the project using the image will continue to + /// run, however new instances can not be created with this image. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` + pub async fn image_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/images/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "image_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn instance_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// until there are no more results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn instance_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_list(organization_name, project_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_list( + organization_name, + project_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an instance + /// + ///Use `POST /v1/instances` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn instance_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::InstanceCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance + /// + ///Use `GET /v1/instances/{instance}` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + pub async fn instance_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` + pub async fn instance_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks + /// + ///Use `GET /v1/instances/{instance}/disks` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn instance_disk_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks as a Stream + /// + ///Use `GET /v1/instances/{instance}/disks` instead + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks` until there are no more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn instance_disk_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_disk_list( + organization_name, + project_name, + instance_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_disk_list( + organization_name, + project_name, + instance_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Attach a disk to an instance + /// + ///Use `POST /v1/instances/{instance}/disks/attach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` + pub async fn instance_disk_attach<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + body: &'a types::DiskIdentifier, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/attach", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Detach a disk from an instance + /// + ///Use `POST /v1/disks/{disk}/detach` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` + pub async fn instance_disk_detach<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + body: &'a types::DiskIdentifier, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/disks/detach", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List external IP addresses + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/external-ips` + pub async fn instance_external_ip_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/external-ips", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_external_ip_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Migrate an instance + /// + ///Use `POST /v1/instances/{instance}/migrate` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` + pub async fn instance_migrate<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + body: &'a types::InstanceMigrate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/migrate", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn instance_network_interface_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List network interfaces as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` until there are no more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn instance_network_interface_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_network_interface_list( + organization_name, + project_name, + instance_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_network_interface_list( + organization_name, + project_name, + instance_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a network interface + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` + pub async fn instance_network_interface_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + body: &'a types::NetworkInterfaceCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a network interface + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + pub async fn instance_network_interface_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + interface_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a network interface + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + pub async fn instance_network_interface_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + interface_name: &'a types::Name, + body: &'a types::NetworkInterfaceUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_network_interface_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a network interface + /// + ///Note that the primary interface for an instance cannot be deleted if + /// there are any secondary interfaces. A new primary interface must be + /// designated first. The primary interface can be deleted if there are no + /// secondary interfaces. + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` + pub async fn instance_network_interface_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + interface_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + encode_path(&interface_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_network_interface_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Reboot an instance + /// + ///Use `POST /v1/instances/{instance}/reboot` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` + pub async fn instance_reboot<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/reboot", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `instance_name` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + pub async fn instance_serial_console<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + from_start: Option, + max_bytes: Option, + most_recent: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Connect to an instance's serial console + /// + ///Use `GET /v1/instances/{instance}/serial-console/stream` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/serial-console/stream` + pub async fn instance_serial_console_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/serial-console/stream", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + + ///Boot an instance + /// + ///Use `POST /v1/instances/{instance}/start` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` + pub async fn instance_start<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/start", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Halt an instance + /// + ///Use `POST /v1/instances/{instance}/stop` instead + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` + pub async fn instance_stop<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + instance_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/instances/{}/stop", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project's IAM policy + /// + ///Use `GET /v1/projects/{project}/policy` instead + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + pub async fn project_policy_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/policy", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn project_policy_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::ProjectRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/policy", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List snapshots + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn snapshot_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List snapshots as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// until there are no more results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn snapshot_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.snapshot_list(organization_name, project_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.snapshot_list( + organization_name, + project_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a snapshot + /// + ///Creates a point-in-time snapshot from a disk. + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn snapshot_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::SnapshotCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "snapshot_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a snapshot + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + pub async fn snapshot_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + snapshot_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a snapshot + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` + pub async fn snapshot_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + snapshot_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/snapshots/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "snapshot_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List VPCs + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn vpc_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List VPCs as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` until + /// there are no more results. + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn vpc_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.vpc_list(organization_name, project_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.vpc_list( + organization_name, + project_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `project_name`: The project's unique name within the organization. + /// - `body` + pub async fn vpc_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + body: &'a types::VpcCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn vpc_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn vpc_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + body: &'a types::VpcUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` + pub async fn vpc_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List firewall rules + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn vpc_firewall_rules_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Replace firewall rules + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` + pub async fn vpc_firewall_rules_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + body: &'a types::VpcFirewallRuleUpdateParams, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_firewall_rules_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List routers + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn vpc_router_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List routers as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` until there are no more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn vpc_router_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.vpc_router_list( + organization_name, + project_name, + vpc_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.vpc_router_list( + organization_name, + project_name, + vpc_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` + pub async fn vpc_router_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + body: &'a types::VpcRouterCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Get a router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn vpc_router_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn vpc_router_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + body: &'a types::VpcRouterUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` + pub async fn vpc_router_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List routes + /// + ///List the routes associated with a router in a particular VPC. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `router_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn vpc_router_route_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List routes as a Stream + /// + ///List the routes associated with a router in a particular VPC. + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` until there are no more + /// results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `router_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn vpc_router_route_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.vpc_router_route_list( + organization_name, + project_name, + vpc_name, + router_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.vpc_router_route_list( + organization_name, + project_name, + vpc_name, + router_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` + pub async fn vpc_router_route_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + body: &'a types::RouterRouteCreateParams, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a route + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn vpc_router_route_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + route_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a route + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn vpc_router_route_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + route_name: &'a types::Name, + body: &'a types::RouterRouteUpdateParams, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_router_route_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a route + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` + pub async fn vpc_router_route_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + router_name: &'a types::Name, + route_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&router_name.to_string()), + encode_path(&route_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_router_route_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List subnets + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn vpc_subnet_list<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List subnets as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` until there are no more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn vpc_subnet_list_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.vpc_subnet_list( + organization_name, + project_name, + vpc_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.vpc_subnet_list( + organization_name, + project_name, + vpc_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a subnet + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` + pub async fn vpc_subnet_create<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + body: &'a types::VpcSubnetCreate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a subnet + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn vpc_subnet_view<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + subnet_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn vpc_subnet_update<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + subnet_name: &'a types::Name, + body: &'a types::VpcSubnetUpdate, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "vpc_subnet_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a subnet + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` + pub async fn vpc_subnet_delete<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + subnet_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List network interfaces + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `subnet_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn vpc_subnet_list_network_interfaces<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + subnet_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}/network-interfaces", + self.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), + encode_path(&subnet_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "vpc_subnet_list_network_interfaces", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List network interfaces as a Stream + /// + ///Sends repeated `GET` requests to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}/network-interfaces` until there are no + /// more results. + /// + ///Arguments: + /// - `organization_name` + /// - `project_name` + /// - `vpc_name` + /// - `subnet_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn vpc_subnet_list_network_interfaces_stream<'a>( + &'a self, + organization_name: &'a types::Name, + project_name: &'a types::Name, + vpc_name: &'a types::Name, + subnet_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.vpc_subnet_list_network_interfaces( + organization_name, + project_name, + vpc_name, + subnet_name, + limit, + None, + sort_by, + ) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.vpc_subnet_list_network_interfaces( + organization_name, + project_name, + vpc_name, + subnet_name, + limit, + state.as_deref(), + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch the current silo's IAM policy + /// + ///Sends a `GET` request to `/policy` + pub async fn policy_view<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/policy", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "policy_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update the current silo's IAM policy + /// + ///Sends a `PUT` request to `/policy` + pub async fn policy_update<'a>( + &'a self, + body: &'a types::SiloRolePolicy, + ) -> Result, Error> { + let url = format!("{}/policy", self.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "policy_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List built-in roles + /// + ///Sends a `GET` request to `/roles` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn role_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!("{}/roles", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List built-in roles as a Stream + /// + ///Sends repeated `GET` requests to `/roles` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + pub fn role_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.role_list(limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.role_list(limit, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a built-in role + /// + ///Sends a `GET` request to `/roles/{role_name}` + /// + ///Arguments: + /// - `role_name`: The built-in role's unique name. + pub async fn role_view<'a>( + &'a self, + role_name: &'a str, + ) -> Result, Error> { + let url = format!( + "{}/roles/{}", + self.baseurl, + encode_path(&role_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "role_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the user associated with the current session + /// + ///Sends a `GET` request to `/session/me` + pub async fn session_me<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/session/me", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the silo groups the current user belongs to + /// + ///Sends a `GET` request to `/session/me/groups` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn session_me_groups<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/session/me/groups", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_me_groups", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the silo groups the current user belongs to as a Stream + /// + ///Sends repeated `GET` requests to `/session/me/groups` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn session_me_groups_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.session_me_groups(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.session_me_groups(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List SSH public keys + /// + ///Lists SSH public keys for the currently authenticated user. + /// + ///Sends a `GET` request to `/session/me/sshkeys` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn session_sshkey_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/session/me/sshkeys", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List SSH public keys as a Stream + /// + ///Lists SSH public keys for the currently authenticated user. + /// + ///Sends repeated `GET` requests to `/session/me/sshkeys` until there are + /// no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn session_sshkey_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.session_sshkey_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.session_sshkey_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an SSH public key + /// + ///Create an SSH public key for the currently authenticated user. + /// + ///Sends a `POST` request to `/session/me/sshkeys` + pub async fn session_sshkey_create<'a>( + &'a self, + body: &'a types::SshKeyCreate, + ) -> Result, Error> { + let url = format!("{}/session/me/sshkeys", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "session_sshkey_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an SSH public key + /// + ///Fetch an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn session_sshkey_view<'a>( + &'a self, + ssh_key_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/session/me/sshkeys/{}", + self.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an SSH public key + /// + ///Delete an SSH public key associated with the currently authenticated + /// user. + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + pub async fn session_sshkey_delete<'a>( + &'a self, + ssh_key_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/session/me/sshkeys/{}", + self.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "session_sshkey_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a system-wide image by id + /// + ///Sends a `GET` request to `/system/by-id/images/{id}` + pub async fn system_image_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/images/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an IP pool by id + /// + ///Sends a `GET` request to `/system/by-id/ip-pools/{id}` + pub async fn ip_pool_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/ip-pools/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a silo by id + /// + ///Sends a `GET` request to `/system/by-id/silos/{id}` + pub async fn silo_view_by_id<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/by-id/silos/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view_by_id", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List system-wide certificates + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends a `GET` request to `/system/certificates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn certificate_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/certificates", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List system-wide certificates as a Stream + /// + ///Returns a list of all the system-wide certificates. System-wide + /// certificates are returned sorted by creation date, with the most recent + /// certificates appearing first. + /// + ///Sends repeated `GET` requests to `/system/certificates` until there are + /// no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn certificate_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.certificate_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.certificate_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a new system-wide x.509 certificate + /// + ///This certificate is automatically used by the Oxide Control plane to + /// serve external connections. + /// + ///Sends a `POST` request to `/system/certificates` + pub async fn certificate_create<'a>( + &'a self, + body: &'a types::CertificateCreate, + ) -> Result, Error> { + let url = format!("{}/system/certificates", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "certificate_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a certificate + /// + ///Returns the details of a specific certificate + /// + ///Sends a `GET` request to `/system/certificates/{certificate}` + pub async fn certificate_view<'a>( + &'a self, + certificate: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/system/certificates/{}", + self.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a certificate + /// + ///Permanently delete a certificate. This operation cannot be undone. + /// + ///Sends a `DELETE` request to `/system/certificates/{certificate}` + pub async fn certificate_delete<'a>( + &'a self, + certificate: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/system/certificates/{}", + self.baseurl, + encode_path(&certificate.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "certificate_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks + /// + ///Sends a `GET` request to `/system/hardware/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn physical_disk_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/disks", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "physical_disk_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/disks` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn physical_disk_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.physical_disk_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.physical_disk_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List racks + /// + ///Sends a `GET` request to `/system/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn rack_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/racks", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List racks as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/racks` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn rack_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.rack_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.rack_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a rack + /// + ///Sends a `GET` request to `/system/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + pub async fn rack_view<'a>( + &'a self, + rack_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/racks/{}", + self.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "rack_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn sled_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/hardware/sleds", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sleds as a Stream + /// + ///Sends repeated `GET` requests to `/system/hardware/sleds` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn sled_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.sled_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.sled_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a sled + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + pub async fn sled_view<'a>( + &'a self, + sled_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/sleds/{}", + self.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks attached to sleds + /// + ///Sends a `GET` request to `/system/hardware/sleds/{sled_id}/disks` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn sled_physical_disk_list<'a>( + &'a self, + sled_id: &'a ::uuid::Uuid, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/system/hardware/sleds/{}/disks", + self.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "sled_physical_disk_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List physical disks attached to sleds as a Stream + /// + ///Sends repeated `GET` requests to + /// `/system/hardware/sleds/{sled_id}/disks` until there are no more + /// results. + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn sled_physical_disk_list_stream<'a>( + &'a self, + sled_id: &'a ::uuid::Uuid, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.sled_physical_disk_list(sled_id, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.sled_physical_disk_list(sled_id, limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List system-wide images + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends a `GET` request to `/system/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_image_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/images", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List system-wide images as a Stream + /// + ///Returns a list of all the system-wide images. System-wide images are + /// returned sorted by creation date, with the most recent images appearing + /// first. + /// + ///Sends repeated `GET` requests to `/system/images` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_image_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_image_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_image_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a system-wide image + /// + ///Create a new system-wide image. This image can then be used by any user + /// in any silo as a base for instances. + /// + ///Sends a `POST` request to `/system/images` + pub async fn system_image_create<'a>( + &'a self, + body: &'a types::GlobalImageCreate, + ) -> Result, Error> { + let url = format!("{}/system/images", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_image_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a system-wide image + /// + ///Returns the details of a specific system-wide image. + /// + ///Sends a `GET` request to `/system/images/{image_name}` + pub async fn system_image_view<'a>( + &'a self, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/images/{}", + self.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a system-wide image + /// + ///Permanently delete a system-wide image. This operation cannot be undone. + /// Any instances using the system-wide image will continue to run, however + /// new instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/system/images/{image_name}` + pub async fn system_image_delete<'a>( + &'a self, + image_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/images/{}", + self.baseurl, + encode_path(&image_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_image_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List IP pools + /// + ///Sends a `GET` request to `/system/ip-pools` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn ip_pool_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List IP pools as a Stream + /// + ///Sends repeated `GET` requests to `/system/ip-pools` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn ip_pool_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools` + pub async fn ip_pool_create<'a>( + &'a self, + body: &'a types::IpPoolCreate, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an IP pool + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_view<'a>( + &'a self, + pool_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an IP Pool + /// + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_update<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpPoolUpdate, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an IP Pool + /// + ///Sends a `DELETE` request to `/system/ip-pools/{pool_name}` + pub async fn ip_pool_delete<'a>( + &'a self, + pool_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for an IP pool + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools/{pool_name}/ranges` + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn ip_pool_range_list<'a>( + &'a self, + pool_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_range_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for an IP pool as a Stream + /// + ///Ranges are ordered by their first address. + /// + ///Sends repeated `GET` requests to `/system/ip-pools/{pool_name}/ranges` + /// until there are no more results. + /// + ///Arguments: + /// - `pool_name` + /// - `limit`: Maximum number of items returned by a single call + pub fn ip_pool_range_list_stream<'a>( + &'a self, + pool_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_range_list(pool_name, limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_range_list(pool_name, limit, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Add a range to an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/add` + pub async fn ip_pool_range_add<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges/add", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_add", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Remove a range from an IP pool + /// + ///Sends a `POST` request to `/system/ip-pools/{pool_name}/ranges/remove` + pub async fn ip_pool_range_remove<'a>( + &'a self, + pool_name: &'a types::Name, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!( + "{}/system/ip-pools/{}/ranges/remove", + self.baseurl, + encode_path(&pool_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_range_remove", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the IP pool used for Oxide services + /// + ///Sends a `GET` request to `/system/ip-pools-service` + pub async fn ip_pool_service_view<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for the IP pool used for Oxide services + /// + ///Ranges are ordered by their first address. + /// + ///Sends a `GET` request to `/system/ip-pools-service/ranges` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn ip_pool_service_range_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List ranges for the IP pool used for Oxide services as a Stream + /// + ///Ranges are ordered by their first address. + /// + ///Sends repeated `GET` requests to `/system/ip-pools-service/ranges` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + pub fn ip_pool_service_range_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.ip_pool_service_range_list(limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.ip_pool_service_range_list(limit, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Add a range to an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/add` + pub async fn ip_pool_service_range_add<'a>( + &'a self, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges/add", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_add", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Remove a range from an IP pool used for Oxide services + /// + ///Sends a `POST` request to `/system/ip-pools-service/ranges/remove` + pub async fn ip_pool_service_range_remove<'a>( + &'a self, + body: &'a types::IpRange, + ) -> Result, Error> { + let url = format!("{}/system/ip-pools-service/ranges/remove", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "ip_pool_service_range_remove", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Access metrics data + /// + ///Sends a `GET` request to `/system/metrics/{metric_name}` + /// + ///Arguments: + /// - `metric_name` + /// - `end_time`: An exclusive end time of metrics. + /// - `id`: The UUID of the container being queried + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `start_time`: An inclusive start time of metrics. + pub async fn system_metric<'a>( + &'a self, + metric_name: types::SystemMetricName, + end_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + id: &'a ::uuid::Uuid, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + start_time: Option<&'a ::chrono::DateTime<::chrono::offset::Utc>>, + ) -> Result, Error> { + let url = format!( + "{}/system/metrics/{}", + self.baseurl, + encode_path(&metric_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("end_time", &end_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("id", &id)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("start_time", &start_time)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_metric", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/system/policy` + pub async fn system_policy_view<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/system/policy", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_policy_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/system/policy` + pub async fn system_policy_update<'a>( + &'a self, + body: &'a types::FleetRolePolicy, + ) -> Result, Error> { + let url = format!("{}/system/policy", self.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_policy_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sagas + /// + ///Sends a `GET` request to `/system/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn saga_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/sagas", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List sagas as a Stream + /// + ///Sends repeated `GET` requests to `/system/sagas` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn saga_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.saga_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.saga_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a saga + /// + ///Sends a `GET` request to `/system/sagas/{saga_id}` + pub async fn saga_view<'a>( + &'a self, + saga_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/sagas/{}", + self.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saga_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List silos + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends a `GET` request to `/system/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn silo_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/silos", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List silos as a Stream + /// + ///Lists silos that are discoverable based on the current permissions. + /// + ///Sends repeated `GET` requests to `/system/silos` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn silo_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.silo_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.silo_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a silo + /// + ///Sends a `POST` request to `/system/silos` + pub async fn silo_create<'a>( + &'a self, + body: &'a types::SiloCreate, + ) -> Result, Error> { + let url = format!("{}/system/silos", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a silo + /// + ///Fetch a silo by name. + /// + ///Sends a `GET` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + pub async fn silo_view<'a>( + &'a self, + silo_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a silo + /// + ///Delete a silo by name. + /// + ///Sends a `DELETE` request to `/system/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + pub async fn silo_delete<'a>( + &'a self, + silo_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List a silo's IDPs + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/identity-providers` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn silo_identity_provider_list<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_identity_provider_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List a silo's IDPs as a Stream + /// + ///Sends repeated `GET` requests to + /// `/system/silos/{silo_name}/identity-providers` until there are no more + /// results. + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn silo_identity_provider_list_stream<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.silo_identity_provider_list(silo_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.silo_identity_provider_list(silo_name, limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a user + /// + ///Users can only be created in Silos with `provision_type` == `Fixed`. + /// Otherwise, Silo users are just-in-time (JIT) provisioned when a user + /// first logs in using an external Identity Provider. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + pub async fn local_idp_user_create<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::UserCreate, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/local/users", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a user + /// + ///Sends a `DELETE` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + pub async fn local_idp_user_delete<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "local_idp_user_delete", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Set or invalidate a user's password + /// + ///Passwords can only be updated for users in Silos with identity mode + /// `LocalOnly`. + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/local/users/{user_id}/ + /// set-password` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + /// - `body` + pub async fn local_idp_user_set_password<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a ::uuid::Uuid, + body: &'a types::UserPassword, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/local/users/{}/set-password", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "local_idp_user_set_password", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Create a SAML IDP + /// + ///Sends a `POST` request to + /// `/system/silos/{silo_name}/identity-providers/saml` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + pub async fn saml_identity_provider_create<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::SamlIdentityProviderCreate, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/saml", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "saml_identity_provider_create", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a SAML IDP + /// + ///Sends a `GET` request to + /// `/system/silos/{silo_name}/identity-providers/saml/{provider_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `provider_name`: The SAML identity provider's name + pub async fn saml_identity_provider_view<'a>( + &'a self, + silo_name: &'a types::Name, + provider_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/identity-providers/saml/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&provider_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "saml_identity_provider_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a silo's IAM policy + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + pub async fn silo_policy_view<'a>( + &'a self, + silo_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/policy", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_policy_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a silo's IAM policy + /// + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + pub async fn silo_policy_update<'a>( + &'a self, + silo_name: &'a types::Name, + body: &'a types::SiloRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/policy", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "silo_policy_update", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List users in a silo + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/all` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn silo_users_list<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/users/all", + self.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_users_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List users in a silo as a Stream + /// + ///Sends repeated `GET` requests to `/system/silos/{silo_name}/users/all` + /// until there are no more results. + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn silo_users_list_stream<'a>( + &'a self, + silo_name: &'a types::Name, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.silo_users_list(silo_name, limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.silo_users_list(silo_name, limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a user + /// + ///Sends a `GET` request to `/system/silos/{silo_name}/users/id/{user_id}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `user_id`: The user's internal id + pub async fn silo_user_view<'a>( + &'a self, + silo_name: &'a types::Name, + user_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/system/silos/{}/users/id/{}", + self.baseurl, + encode_path(&silo_name.to_string()), + encode_path(&user_id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "silo_user_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List built-in users + /// + ///Sends a `GET` request to `/system/user` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_user_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/system/user", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List built-in users as a Stream + /// + ///Sends repeated `GET` requests to `/system/user` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_user_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_user_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_user_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a built-in user + /// + ///Sends a `GET` request to `/system/user/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. + pub async fn system_user_view<'a>( + &'a self, + user_name: &'a types::Name, + ) -> Result, Error> { + let url = format!( + "{}/system/user/{}", + self.baseurl, + encode_path(&user_name.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_user_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List timeseries schema + /// + ///Sends a `GET` request to `/timeseries/schema` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + pub async fn timeseries_schema_get<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + ) -> Result, Error> { + let url = format!("{}/timeseries/schema", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "timeseries_schema_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List timeseries schema as a Stream + /// + ///Sends repeated `GET` requests to `/timeseries/schema` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + pub fn timeseries_schema_get_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.timeseries_schema_get(limit, None) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.timeseries_schema_get(limit, state.as_deref()) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List users + /// + ///Sends a `GET` request to `/users` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn user_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/users", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "user_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List users as a Stream + /// + ///Sends repeated `GET` requests to `/users` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn user_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.user_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.user_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List disks + /// + ///Sends a `GET` request to `/v1/disks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn disk_list_v1<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/disks", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_list_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List disks as a Stream + /// + ///Sends repeated `GET` requests to `/v1/disks` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn disk_list_v1_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.disk_list_v1(limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.disk_list_v1(limit, None, state.as_deref(), None, None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a disk + /// + ///Sends a `POST` request to `/v1/disks` + pub async fn disk_create_v1<'a>( + &'a self, + organization: Option<&'a types::NameOrId>, + project: &'a types::NameOrId, + body: &'a types::DiskCreate, + ) -> Result, Error> { + let url = format!("{}/v1/disks", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "disk_create_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a disk + /// + ///Sends a `GET` request to `/v1/disks/{disk}` + pub async fn disk_view_v1<'a>( + &'a self, + disk: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/disks/{}", + self.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a disk + /// + ///Sends a `DELETE` request to `/v1/disks/{disk}` + pub async fn disk_delete_v1<'a>( + &'a self, + disk: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/disks/{}", + self.baseurl, + encode_path(&disk.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "disk_delete_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances + /// + ///Sends a `GET` request to `/v1/instances` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn instance_list_v1<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/instances", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_list_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List instances as a Stream + /// + ///Sends repeated `GET` requests to `/v1/instances` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn instance_list_v1_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_list_v1(limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_list_v1(limit, None, state.as_deref(), None, None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an instance + /// + ///Sends a `POST` request to `/v1/instances` + pub async fn instance_create_v1<'a>( + &'a self, + organization: Option<&'a types::NameOrId>, + project: &'a types::NameOrId, + body: &'a types::InstanceCreate, + ) -> Result, Error> { + let url = format!("{}/v1/instances", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_create_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance + /// + ///Sends a `GET` request to `/v1/instances/{instance}` + pub async fn instance_view_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an instance + /// + ///Sends a `DELETE` request to `/v1/instances/{instance}` + pub async fn instance_delete_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_delete_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks + /// + ///Sends a `GET` request to `/v1/instances/{instance}/disks` + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `project` + /// - `sort_by` + pub async fn instance_disk_list_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_disk_list_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List an instance's disks as a Stream + /// + ///Sends repeated `GET` requests to `/v1/instances/{instance}/disks` until + /// there are no more results. + /// + ///Arguments: + /// - `instance` + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `project` + /// - `sort_by` + pub fn instance_disk_list_v1_stream<'a>( + &'a self, + instance: &'a types::NameOrId, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.instance_disk_list_v1(instance, limit, organization, None, project, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.instance_disk_list_v1( + instance, + limit, + None, + state.as_deref(), + None, + None, + ) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Attach a disk to an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` + pub async fn instance_disk_attach_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::DiskPath, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks/attach", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_attach_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Detach a disk from an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` + pub async fn instance_disk_detach_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::DiskPath, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/disks/detach", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_disk_detach_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Migrate an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` + pub async fn instance_migrate_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + body: &'a types::InstanceMigrate, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/migrate", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Reboot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/reboot` + pub async fn instance_reboot_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/reboot", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_reboot_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an instance's serial console + /// + ///Sends a `GET` request to `/v1/instances/{instance}/serial-console` + /// + ///Arguments: + /// - `instance` + /// - `from_start`: Character index in the serial buffer from which to read, + /// counting the bytes output since instance start. If this is not + /// provided, `most_recent` must be provided, and if this *is* provided, + /// `most_recent` must *not* be provided. + /// - `max_bytes`: Maximum number of bytes of buffered serial console + /// contents to return. If the requested range runs to the end of the + /// available buffer, the data returned will be shorter than `max_bytes`. + /// - `most_recent`: Character index in the serial buffer from which to + /// read, counting *backward* from the most recently buffered data + /// retrieved from the instance. (See note on `from_start` about mutual + /// exclusivity) + /// - `organization` + /// - `project` + pub async fn instance_serial_console_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + from_start: Option, + max_bytes: Option, + most_recent: Option, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/serial-console", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("from_start", &from_start)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("max_bytes", &max_bytes)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("most_recent", &most_recent)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_serial_console_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stream an instance's serial console + /// + ///Sends a `GET` request to + /// `/v1/instances/{instance}/serial-console/stream` + pub async fn instance_serial_console_stream_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/serial-console/stream", + self.baseurl, + encode_path(&instance.to_string()), + ); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + + ///Boot an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/start` + pub async fn instance_start_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/start", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_start_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stop an instance + /// + ///Sends a `POST` request to `/v1/instances/{instance}/stop` + pub async fn instance_stop_v1<'a>( + &'a self, + instance: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + project: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/instances/{}/stop", + self.baseurl, + encode_path(&instance.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("project", &project)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_stop_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations + /// + ///Sends a `GET` request to `/v1/organizations` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn organization_list_v1<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/organizations", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_list_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List organizations as a Stream + /// + ///Sends repeated `GET` requests to `/v1/organizations` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn organization_list_v1_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.organization_list_v1(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.organization_list_v1(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create an organization + /// + ///Sends a `POST` request to `/v1/organizations` + pub async fn organization_create_v1<'a>( + &'a self, + body: &'a types::OrganizationCreate, + ) -> Result, Error> { + let url = format!("{}/v1/organizations", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_create_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization + /// + ///Sends a `GET` request to `/v1/organizations/{organization}` + pub async fn organization_view_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}` + pub async fn organization_update_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::OrganizationUpdate, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_update_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete an organization + /// + ///Sends a `DELETE` request to `/v1/organizations/{organization}` + pub async fn organization_delete_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_delete_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch an organization's IAM policy + /// + ///Sends a `GET` request to `/v1/organizations/{organization}/policy` + pub async fn organization_policy_view_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}/policy", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "organization_policy_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update an organization's IAM policy + /// + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` + pub async fn organization_policy_update_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::OrganizationRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/v1/organizations/{}/policy", + self.baseurl, + encode_path(&organization.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "organization_policy_update_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects + /// + ///Sends a `GET` request to `/v1/projects` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn project_list_v1<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/projects", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_list_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List projects as a Stream + /// + ///Sends repeated `GET` requests to `/v1/projects` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `organization` + /// - `sort_by` + pub fn project_list_v1_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + organization: Option<&'a types::NameOrId>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.project_list_v1(limit, organization, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.project_list_v1(limit, None, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Create a project + /// + ///Sends a `POST` request to `/v1/projects` + pub async fn project_create_v1<'a>( + &'a self, + organization: &'a types::NameOrId, + body: &'a types::ProjectCreate, + ) -> Result, Error> { + let url = format!("{}/v1/projects", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_create_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project + /// + ///Sends a `GET` request to `/v1/projects/{project}` + pub async fn project_view_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project + /// + ///Sends a `PUT` request to `/v1/projects/{project}` + pub async fn project_update_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + body: &'a types::ProjectUpdate, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_update_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Delete a project + /// + ///Sends a `DELETE` request to `/v1/projects/{project}` + pub async fn project_delete_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}", + self.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::delete(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_delete_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Fetch a project's IAM policy + /// + ///Sends a `GET` request to `/v1/projects/{project}/policy` + pub async fn project_policy_view_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}/policy", + self.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "project_policy_view_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Update a project's IAM policy + /// + ///Sends a `PUT` request to `/v1/projects/{project}/policy` + pub async fn project_policy_update_v1<'a>( + &'a self, + project: &'a types::NameOrId, + organization: Option<&'a types::NameOrId>, + body: &'a types::ProjectRolePolicy, + ) -> Result, Error> { + let url = format!( + "{}/v1/projects/{}/policy", + self.baseurl, + encode_path(&project.to_string()), + ); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("organization", &organization)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "project_policy_update_v1", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View version and update status of component tree + /// + ///Sends a `GET` request to `/v1/system/update/components` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_component_version_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/components", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_component_version_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View version and update status of component tree as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/components` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_component_version_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_component_version_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_component_version_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///List all update deployments + /// + ///Sends a `GET` request to `/v1/system/update/deployments` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn update_deployments_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/deployments", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployments_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all update deployments as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/deployments` until + /// there are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn update_deployments_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.update_deployments_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.update_deployments_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///Fetch a system update deployment + /// + ///Sends a `GET` request to `/v1/system/update/deployments/{id}` + pub async fn update_deployment_view<'a>( + &'a self, + id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/deployments/{}", + self.baseurl, + encode_path(&id.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "update_deployment_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Refresh update data + /// + ///Sends a `POST` request to `/v1/system/update/refresh` + pub async fn system_update_refresh<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/refresh", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_refresh", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Start system update + /// + ///Sends a `POST` request to `/v1/system/update/start` + pub async fn system_update_start<'a>( + &'a self, + body: &'a types::SystemUpdateStart, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/start", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "system_update_start", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 202u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Stop system update + /// + ///If there is no update in progress, do nothing. + /// + ///Sends a `POST` request to `/v1/system/update/stop` + pub async fn system_update_stop<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/stop", self.baseurl,); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_stop", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all updates + /// + ///Sends a `GET` request to `/v1/system/update/updates` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// - `sort_by` + pub async fn system_update_list<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + page_token: Option<&'a str>, + sort_by: Option, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/updates", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .query( + ::serde_urlencoded::to_string([("limit", &limit)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("page_token", &page_token)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("sort_by", &sort_by)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///List all updates as a Stream + /// + ///Sends repeated `GET` requests to `/v1/system/update/updates` until there + /// are no more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` + pub fn system_update_list_stream<'a>( + &'a self, + limit: Option<::std::num::NonZeroU32>, + sort_by: Option, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + self.system_update_list(limit, None, sort_by) + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold(page.next_page, move |state| async move { + if state.is_none() { + Ok(None) + } else { + self.system_update_list(limit, state.as_deref(), None) + .map_ok(|page| { + let page = page.into_inner(); + Some((futures::stream::iter(page.items).map(Ok), page.next_page)) + }) + .await + } + }) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed_local() + } + + ///View system update + /// + ///Sends a `GET` request to `/v1/system/update/updates/{version}` + pub async fn system_update_view<'a>( + &'a self, + version: &'a types::SemverVersion, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/updates/{}", + self.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_view", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View system update component tree + /// + ///Sends a `GET` request to + /// `/v1/system/update/updates/{version}/components` + pub async fn system_update_components_list<'a>( + &'a self, + version: &'a types::SemverVersion, + ) -> Result, Error> { + let url = format!( + "{}/v1/system/update/updates/{}/components", + self.baseurl, + encode_path(&version.to_string()), + ); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_update_components_list", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///View system version and update status + /// + ///Sends a `GET` request to `/v1/system/update/version` + pub async fn system_version<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/v1/system/update/version", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "system_version", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder.rs new file mode 100644 index 00000000..ed5b1344 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder.rs @@ -0,0 +1,286 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter name collision test +/// +///Minimal API for testing collision between parameter names and generated code +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key/{query}` + /// + ///Arguments: + /// - `query`: Parameter name that was previously colliding + /// - `client`: Parameter name that was previously colliding + /// - `request`: Parameter name that was previously colliding + /// - `response`: Parameter name that was previously colliding + /// - `result`: Parameter name that was previously colliding + /// - `url`: Parameter name that was previously colliding + ///```ignore + /// let response = client.key_get() + /// .query(query) + /// .client(client) + /// .request(request) + /// .response(response) + /// .result(result) + /// .url(url) + /// .send() + /// .await; + /// ``` + pub fn key_get(&self) -> builder::KeyGet<'_> { + builder::KeyGet::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::key_get`] + /// + ///[`Client::key_get`]: super::Client::key_get + #[derive(Debug, Clone)] + pub struct KeyGet<'a> { + _client: &'a super::Client, + query: Result, + client: Result, + request: Result, + response: Result, + result: Result, + url: Result, + } + + impl<'a> KeyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + _client: client, + query: Err("query was not initialized".to_string()), + client: Err("client was not initialized".to_string()), + request: Err("request was not initialized".to_string()), + response: Err("response was not initialized".to_string()), + result: Err("result was not initialized".to_string()), + url: Err("url was not initialized".to_string()), + } + } + + pub fn query(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.query = value + .try_into() + .map_err(|_| "conversion to `bool` for query failed".to_string()); + self + } + + pub fn client(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.client = value + .try_into() + .map_err(|_| "conversion to `bool` for client failed".to_string()); + self + } + + pub fn request(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.request = value + .try_into() + .map_err(|_| "conversion to `bool` for request failed".to_string()); + self + } + + pub fn response(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.response = value + .try_into() + .map_err(|_| "conversion to `bool` for response failed".to_string()); + self + } + + pub fn result(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.result = value + .try_into() + .map_err(|_| "conversion to `bool` for result failed".to_string()); + self + } + + pub fn url(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.url = value + .try_into() + .map_err(|_| "conversion to `bool` for url failed".to_string()); + self + } + + ///Sends a `GET` request to `/key/{query}` + pub async fn send(self) -> Result, Error<()>> { + let Self { + _client, + query, + client, + request, + response, + result, + url, + } = self; + let query = query.map_err(Error::InvalidRequest)?; + let client = client.map_err(Error::InvalidRequest)?; + let request = request.map_err(Error::InvalidRequest)?; + let response = response.map_err(Error::InvalidRequest)?; + let result = result.map_err(Error::InvalidRequest)?; + let url = url.map_err(Error::InvalidRequest)?; + let _url = format!( + "{}/key/{}", + _client.baseurl, + encode_path(&query.to_string()), + ); + let _request = ::gloo_net::http::Request::get(&_url) + .query( + ::serde_urlencoded::to_string([("client", &client)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("request", &request)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("response", &response)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("result", &result)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("url", &url)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let _result = _client.exec(_request, &info).await; + _client.post(&_result, &info).await?; + let _response = _result?; + match _response.status() { + 200u16 => Ok(ResponseValue::empty(_response)), + _ => Err(Error::UnexpectedResponse(_response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder_tagged.rs new file mode 100644 index 00000000..d293a35c --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_collision_builder_tagged.rs @@ -0,0 +1,288 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter name collision test +/// +///Minimal API for testing collision between parameter names and generated code +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key/{query}` + /// + ///Arguments: + /// - `query`: Parameter name that was previously colliding + /// - `client`: Parameter name that was previously colliding + /// - `request`: Parameter name that was previously colliding + /// - `response`: Parameter name that was previously colliding + /// - `result`: Parameter name that was previously colliding + /// - `url`: Parameter name that was previously colliding + ///```ignore + /// let response = client.key_get() + /// .query(query) + /// .client(client) + /// .request(request) + /// .response(response) + /// .result(result) + /// .url(url) + /// .send() + /// .await; + /// ``` + pub fn key_get(&self) -> builder::KeyGet<'_> { + builder::KeyGet::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::key_get`] + /// + ///[`Client::key_get`]: super::Client::key_get + #[derive(Debug, Clone)] + pub struct KeyGet<'a> { + _client: &'a super::Client, + query: Result, + client: Result, + request: Result, + response: Result, + result: Result, + url: Result, + } + + impl<'a> KeyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + _client: client, + query: Err("query was not initialized".to_string()), + client: Err("client was not initialized".to_string()), + request: Err("request was not initialized".to_string()), + response: Err("response was not initialized".to_string()), + result: Err("result was not initialized".to_string()), + url: Err("url was not initialized".to_string()), + } + } + + pub fn query(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.query = value + .try_into() + .map_err(|_| "conversion to `bool` for query failed".to_string()); + self + } + + pub fn client(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.client = value + .try_into() + .map_err(|_| "conversion to `bool` for client failed".to_string()); + self + } + + pub fn request(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.request = value + .try_into() + .map_err(|_| "conversion to `bool` for request failed".to_string()); + self + } + + pub fn response(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.response = value + .try_into() + .map_err(|_| "conversion to `bool` for response failed".to_string()); + self + } + + pub fn result(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.result = value + .try_into() + .map_err(|_| "conversion to `bool` for result failed".to_string()); + self + } + + pub fn url(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.url = value + .try_into() + .map_err(|_| "conversion to `bool` for url failed".to_string()); + self + } + + ///Sends a `GET` request to `/key/{query}` + pub async fn send(self) -> Result, Error<()>> { + let Self { + _client, + query, + client, + request, + response, + result, + url, + } = self; + let query = query.map_err(Error::InvalidRequest)?; + let client = client.map_err(Error::InvalidRequest)?; + let request = request.map_err(Error::InvalidRequest)?; + let response = response.map_err(Error::InvalidRequest)?; + let result = result.map_err(Error::InvalidRequest)?; + let url = url.map_err(Error::InvalidRequest)?; + let _url = format!( + "{}/key/{}", + _client.baseurl, + encode_path(&query.to_string()), + ); + let _request = ::gloo_net::http::Request::get(&_url) + .query( + ::serde_urlencoded::to_string([("client", &client)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("request", &request)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("response", &response)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("result", &result)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("url", &url)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let _result = _client.exec(_request, &info).await; + _client.post(&_result, &info).await?; + let _response = _result?; + match _response.status() { + 200u16 => Ok(ResponseValue::empty(_response)), + _ => Err(Error::UnexpectedResponse(_response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_collision_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/param_collision_positional.rs new file mode 100644 index 00000000..a6649c3e --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_collision_positional.rs @@ -0,0 +1,163 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter name collision test +/// +///Minimal API for testing collision between parameter names and generated code +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key/{query}` + /// + ///Arguments: + /// - `query`: Parameter name that was previously colliding + /// - `client`: Parameter name that was previously colliding + /// - `request`: Parameter name that was previously colliding + /// - `response`: Parameter name that was previously colliding + /// - `result`: Parameter name that was previously colliding + /// - `url`: Parameter name that was previously colliding + pub async fn key_get<'a>( + &'a self, + query: bool, + client: bool, + request: bool, + response: bool, + result: bool, + url: bool, + ) -> Result, Error<()>> { + let _url = format!("{}/key/{}", self.baseurl, encode_path(&query.to_string()),); + let _request = ::gloo_net::http::Request::get(&_url) + .query( + ::serde_urlencoded::to_string([("client", &client)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("request", &request)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("response", &response)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("result", &result)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("url", &url)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let _result = self.exec(_request, &info).await; + self.post(&_result, &info).await?; + let _response = _result?; + match _response.status() { + 200u16 => Ok(ResponseValue::empty(_response)), + _ => Err(Error::UnexpectedResponse(_response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder.rs new file mode 100644 index 00000000..0fc60fcc --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder.rs @@ -0,0 +1,194 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key` + /// + ///Arguments: + /// - `key`: The same key parameter that overlaps with the path level + /// parameter + /// - `unique_key`: A key parameter that will not be overridden by the path + /// spec + ///```ignore + /// let response = client.key_get() + /// .key(key) + /// .unique_key(unique_key) + /// .send() + /// .await; + /// ``` + pub fn key_get(&self) -> builder::KeyGet<'_> { + builder::KeyGet::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::key_get`] + /// + ///[`Client::key_get`]: super::Client::key_get + #[derive(Debug, Clone)] + pub struct KeyGet<'a> { + client: &'a super::Client, + key: Result, String>, + unique_key: Result, String>, + } + + impl<'a> KeyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + key: Ok(None), + unique_key: Ok(None), + } + } + + pub fn key(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.key = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `bool` for key failed".to_string()); + self + } + + pub fn unique_key(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.unique_key = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for unique_key failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/key` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + key, + unique_key, + } = self; + let key = key.map_err(Error::InvalidRequest)?; + let unique_key = unique_key.map_err(Error::InvalidRequest)?; + let url = format!("{}/key", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("key", &key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("uniqueKey", &unique_key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder_tagged.rs new file mode 100644 index 00000000..c5d61486 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_builder_tagged.rs @@ -0,0 +1,196 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key` + /// + ///Arguments: + /// - `key`: The same key parameter that overlaps with the path level + /// parameter + /// - `unique_key`: A key parameter that will not be overridden by the path + /// spec + ///```ignore + /// let response = client.key_get() + /// .key(key) + /// .unique_key(unique_key) + /// .send() + /// .await; + /// ``` + pub fn key_get(&self) -> builder::KeyGet<'_> { + builder::KeyGet::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::key_get`] + /// + ///[`Client::key_get`]: super::Client::key_get + #[derive(Debug, Clone)] + pub struct KeyGet<'a> { + client: &'a super::Client, + key: Result, String>, + unique_key: Result, String>, + } + + impl<'a> KeyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + key: Ok(None), + unique_key: Ok(None), + } + } + + pub fn key(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.key = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `bool` for key failed".to_string()); + self + } + + pub fn unique_key(mut self, value: V) -> Self + where + V: std::convert::TryInto<::std::string::String>, + { + self.unique_key = value.try_into().map(Some).map_err(|_| { + "conversion to `:: std :: string :: String` for unique_key failed".to_string() + }); + self + } + + ///Sends a `GET` request to `/key` + pub async fn send(self) -> Result, Error<()>> { + let Self { + client, + key, + unique_key, + } = self; + let key = key.map_err(Error::InvalidRequest)?; + let unique_key = unique_key.map_err(Error::InvalidRequest)?; + let url = format!("{}/key", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("key", &key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("uniqueKey", &unique_key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/param_overrides_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_positional.rs new file mode 100644 index 00000000..fc8207b6 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/param_overrides_positional.rs @@ -0,0 +1,130 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Parameter override test +/// +///Minimal API for testing parameter overrides +/// +///Version: v1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "v1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Gets a key + /// + ///Sends a `GET` request to `/key` + /// + ///Arguments: + /// - `key`: The same key parameter that overlaps with the path level + /// parameter + /// - `unique_key`: A key parameter that will not be overridden by the path + /// spec + pub async fn key_get<'a>( + &'a self, + key: Option, + unique_key: Option<&'a str>, + ) -> Result, Error<()>> { + let url = format!("{}/key", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .query( + ::serde_urlencoded::to_string([("key", &key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .query( + ::serde_urlencoded::to_string([("uniqueKey", &unique_key)]) + .map_err(|e| Error::InvalidRequest(e.to_string()))? + .split('&') + .filter_map(|pair| { + let mut parts = pair.splitn(2, '='); + Some((parts.next()?, parts.next().unwrap_or(""))) + }), + ) + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "key_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder.rs b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder.rs new file mode 100644 index 00000000..1f3f2499 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder.rs @@ -0,0 +1,3548 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`CrucibleOpts` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "lossy", + /// "read_only", + /// "target" + /// ], + /// "properties": { + /// "cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "control": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "flush_timeout": { + /// "type": [ + /// "integer", + /// "null" + /// ], + /// "format": "uint32", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "key": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "key_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "lossy": { + /// "type": "boolean" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "root_cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "target": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct CrucibleOpts { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cert_pem: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub control: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub flush_timeout: ::std::option::Option, + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key_pem: ::std::option::Option<::std::string::String>, + pub lossy: bool, + pub read_only: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub root_cert_pem: ::std::option::Option<::std::string::String>, + pub target: ::std::vec::Vec<::std::string::String>, + } + + impl ::std::convert::From<&CrucibleOpts> for CrucibleOpts { + fn from(value: &CrucibleOpts) -> Self { + value.clone() + } + } + + impl CrucibleOpts { + pub fn builder() -> builder::CrucibleOpts { + Default::default() + } + } + + ///`DiskAttachment` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk_id", + /// "generation_id", + /// "state" + /// ], + /// "properties": { + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "generation_id": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskAttachmentState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskAttachment { + pub disk_id: ::uuid::Uuid, + pub generation_id: u64, + pub state: DiskAttachmentState, + } + + impl ::std::convert::From<&DiskAttachment> for DiskAttachment { + fn from(value: &DiskAttachment) -> Self { + value.clone() + } + } + + impl DiskAttachment { + pub fn builder() -> builder::DiskAttachment { + Default::default() + } + } + + ///`DiskAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Destroyed", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "type": "string", + /// "format": "uuid" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub enum DiskAttachmentState { + Detached, + Destroyed, + Faulted, + Attached(::uuid::Uuid), + } + + impl ::std::convert::From<&Self> for DiskAttachmentState { + fn from(value: &DiskAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::uuid::Uuid> for DiskAttachmentState { + fn from(value: ::uuid::Uuid) -> Self { + Self::Attached(value) + } + } + + ///`DiskRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "device", + /// "gen", + /// "name", + /// "read_only", + /// "slot", + /// "volume_construction_request" + /// ], + /// "properties": { + /// "device": { + /// "type": "string" + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// }, + /// "volume_construction_request": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct DiskRequest { + pub device: ::std::string::String, + pub gen: u64, + pub name: ::std::string::String, + pub read_only: bool, + pub slot: Slot, + pub volume_construction_request: VolumeConstructionRequest, + } + + impl ::std::convert::From<&DiskRequest> for DiskRequest { + fn from(value: &DiskRequest) -> Self { + value.clone() + } + } + + impl DiskRequest { + pub fn builder() -> builder::DiskRequest { + Default::default() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + impl Error { + pub fn builder() -> builder::Error { + Default::default() + } + } + + ///`Instance` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disks", + /// "nics", + /// "properties", + /// "state" + /// ], + /// "properties": { + /// "disks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskAttachment" + /// } + /// }, + /// "nics": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct Instance { + pub disks: ::std::vec::Vec, + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + pub state: InstanceState, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + impl Instance { + pub fn builder() -> builder::Instance { + Default::default() + } + } + + ///`InstanceEnsureRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "properties" + /// ], + /// "properties": { + /// "cloud_init_bytes": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "disks": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskRequest" + /// } + /// }, + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "nics": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceRequest" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceEnsureRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cloud_init_bytes: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + } + + impl ::std::convert::From<&InstanceEnsureRequest> for InstanceEnsureRequest { + fn from(value: &InstanceEnsureRequest) -> Self { + value.clone() + } + } + + impl InstanceEnsureRequest { + pub fn builder() -> builder::InstanceEnsureRequest { + Default::default() + } + } + + ///`InstanceEnsureResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "properties": { + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateResponse" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceEnsureResponse { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + } + + impl ::std::convert::From<&InstanceEnsureResponse> for InstanceEnsureResponse { + fn from(value: &InstanceEnsureResponse) -> Self { + value.clone() + } + } + + impl ::std::default::Default for InstanceEnsureResponse { + fn default() -> Self { + Self { + migrate: Default::default(), + } + } + } + + impl InstanceEnsureResponse { + pub fn builder() -> builder::InstanceEnsureResponse { + Default::default() + } + } + + ///`InstanceGetResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "instance" + /// ], + /// "properties": { + /// "instance": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceGetResponse { + pub instance: Instance, + } + + impl ::std::convert::From<&InstanceGetResponse> for InstanceGetResponse { + fn from(value: &InstanceGetResponse) -> Self { + value.clone() + } + } + + impl InstanceGetResponse { + pub fn builder() -> builder::InstanceGetResponse { + Default::default() + } + } + + ///`InstanceMigrateInitiateRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id", + /// "src_addr", + /// "src_uuid" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "src_addr": { + /// "type": "string" + /// }, + /// "src_uuid": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceMigrateInitiateRequest { + pub migration_id: ::uuid::Uuid, + pub src_addr: ::std::string::String, + pub src_uuid: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateRequest> for InstanceMigrateInitiateRequest { + fn from(value: &InstanceMigrateInitiateRequest) -> Self { + value.clone() + } + } + + impl InstanceMigrateInitiateRequest { + pub fn builder() -> builder::InstanceMigrateInitiateRequest { + Default::default() + } + } + + ///`InstanceMigrateInitiateResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceMigrateInitiateResponse { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateResponse> for InstanceMigrateInitiateResponse { + fn from(value: &InstanceMigrateInitiateResponse) -> Self { + value.clone() + } + } + + impl InstanceMigrateInitiateResponse { + pub fn builder() -> builder::InstanceMigrateInitiateResponse { + Default::default() + } + } + + ///`InstanceMigrateStatusRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceMigrateStatusRequest { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateStatusRequest> for InstanceMigrateStatusRequest { + fn from(value: &InstanceMigrateStatusRequest) -> Self { + value.clone() + } + } + + impl InstanceMigrateStatusRequest { + pub fn builder() -> builder::InstanceMigrateStatusRequest { + Default::default() + } + } + + ///`InstanceMigrateStatusResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "$ref": "#/components/schemas/MigrationState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceMigrateStatusResponse { + pub state: MigrationState, + } + + impl ::std::convert::From<&InstanceMigrateStatusResponse> for InstanceMigrateStatusResponse { + fn from(value: &InstanceMigrateStatusResponse) -> Self { + value.clone() + } + } + + impl InstanceMigrateStatusResponse { + pub fn builder() -> builder::InstanceMigrateStatusResponse { + Default::default() + } + } + + ///`InstanceProperties` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootrom_id", + /// "description", + /// "id", + /// "image_id", + /// "memory", + /// "name", + /// "vcpus" + /// ], + /// "properties": { + /// "bootrom_id": { + /// "description": "ID of the bootrom used to initialize this + /// Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "description": { + /// "description": "Free-form text description of an Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "Unique identifier for this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "description": "ID of the image used to initialize this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "Size of memory allocated to the Instance, in MiB.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "description": "Human-readable name of the Instance.", + /// "type": "string" + /// }, + /// "vcpus": { + /// "description": "Number of vCPUs to be allocated to the Instance.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceProperties { + ///ID of the bootrom used to initialize this Instance. + pub bootrom_id: ::uuid::Uuid, + ///Free-form text description of an Instance. + pub description: ::std::string::String, + ///Unique identifier for this Instance. + pub id: ::uuid::Uuid, + ///ID of the image used to initialize this Instance. + pub image_id: ::uuid::Uuid, + ///Size of memory allocated to the Instance, in MiB. + pub memory: u64, + ///Human-readable name of the Instance. + pub name: ::std::string::String, + ///Number of vCPUs to be allocated to the Instance. + pub vcpus: u8, + } + + impl ::std::convert::From<&InstanceProperties> for InstanceProperties { + fn from(value: &InstanceProperties) -> Self { + value.clone() + } + } + + impl InstanceProperties { + pub fn builder() -> builder::InstanceProperties { + Default::default() + } + } + + ///Current state of an Instance. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Current state of an Instance.", + /// "type": "string", + /// "enum": [ + /// "Creating", + /// "Starting", + /// "Running", + /// "Stopping", + /// "Stopped", + /// "Rebooting", + /// "Migrating", + /// "Repairing", + /// "Failed", + /// "Destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum InstanceState { + Creating, + Starting, + Running, + Stopping, + Stopped, + Rebooting, + Migrating, + Repairing, + Failed, + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("Creating"), + Self::Starting => f.write_str("Starting"), + Self::Running => f.write_str("Running"), + Self::Stopping => f.write_str("Stopping"), + Self::Stopped => f.write_str("Stopped"), + Self::Rebooting => f.write_str("Rebooting"), + Self::Migrating => f.write_str("Migrating"), + Self::Repairing => f.write_str("Repairing"), + Self::Failed => f.write_str("Failed"), + Self::Destroyed => f.write_str("Destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Creating" => Ok(Self::Creating), + "Starting" => Ok(Self::Starting), + "Running" => Ok(Self::Running), + "Stopping" => Ok(Self::Stopping), + "Stopped" => Ok(Self::Stopped), + "Rebooting" => Ok(Self::Rebooting), + "Migrating" => Ok(Self::Migrating), + "Repairing" => Ok(Self::Repairing), + "Failed" => Ok(Self::Failed), + "Destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`InstanceStateMonitorRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceStateMonitorRequest { + pub gen: u64, + } + + impl ::std::convert::From<&InstanceStateMonitorRequest> for InstanceStateMonitorRequest { + fn from(value: &InstanceStateMonitorRequest) -> Self { + value.clone() + } + } + + impl InstanceStateMonitorRequest { + pub fn builder() -> builder::InstanceStateMonitorRequest { + Default::default() + } + } + + ///`InstanceStateMonitorResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen", + /// "state" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct InstanceStateMonitorResponse { + pub gen: u64, + pub state: InstanceState, + } + + impl ::std::convert::From<&InstanceStateMonitorResponse> for InstanceStateMonitorResponse { + fn from(value: &InstanceStateMonitorResponse) -> Self { + value.clone() + } + } + + impl InstanceStateMonitorResponse { + pub fn builder() -> builder::InstanceStateMonitorResponse { + Default::default() + } + } + + ///`InstanceStateRequested` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Run", + /// "Stop", + /// "Reboot", + /// "MigrateStart" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum InstanceStateRequested { + Run, + Stop, + Reboot, + MigrateStart, + } + + impl ::std::convert::From<&Self> for InstanceStateRequested { + fn from(value: &InstanceStateRequested) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceStateRequested { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Run => f.write_str("Run"), + Self::Stop => f.write_str("Stop"), + Self::Reboot => f.write_str("Reboot"), + Self::MigrateStart => f.write_str("MigrateStart"), + } + } + } + + impl ::std::str::FromStr for InstanceStateRequested { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Run" => Ok(Self::Run), + "Stop" => Ok(Self::Stop), + "Reboot" => Ok(Self::Reboot), + "MigrateStart" => Ok(Self::MigrateStart), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`MigrationState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Sync", + /// "RamPush", + /// "Pause", + /// "RamPushDirty", + /// "Device", + /// "Arch", + /// "Resume", + /// "RamPull", + /// "Finish", + /// "Error" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + schemars :: JsonSchema, + )] + pub enum MigrationState { + Sync, + RamPush, + Pause, + RamPushDirty, + Device, + Arch, + Resume, + RamPull, + Finish, + Error, + } + + impl ::std::convert::From<&Self> for MigrationState { + fn from(value: &MigrationState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for MigrationState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Sync => f.write_str("Sync"), + Self::RamPush => f.write_str("RamPush"), + Self::Pause => f.write_str("Pause"), + Self::RamPushDirty => f.write_str("RamPushDirty"), + Self::Device => f.write_str("Device"), + Self::Arch => f.write_str("Arch"), + Self::Resume => f.write_str("Resume"), + Self::RamPull => f.write_str("RamPull"), + Self::Finish => f.write_str("Finish"), + Self::Error => f.write_str("Error"), + } + } + } + + impl ::std::str::FromStr for MigrationState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Sync" => Ok(Self::Sync), + "RamPush" => Ok(Self::RamPush), + "Pause" => Ok(Self::Pause), + "RamPushDirty" => Ok(Self::RamPushDirty), + "Device" => Ok(Self::Device), + "Arch" => Ok(Self::Arch), + "Resume" => Ok(Self::Resume), + "RamPull" => Ok(Self::RamPull), + "Finish" => Ok(Self::Finish), + "Error" => Ok(Self::Error), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for MigrationState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`NetworkInterface` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "attachment", + /// "name" + /// ], + /// "properties": { + /// "attachment": { + /// "$ref": "#/components/schemas/NetworkInterfaceAttachmentState" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterface { + pub attachment: NetworkInterfaceAttachmentState, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + impl NetworkInterface { + pub fn builder() -> builder::NetworkInterface { + Default::default() + } + } + + ///`NetworkInterfaceAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub enum NetworkInterfaceAttachmentState { + Detached, + Faulted, + Attached(Slot), + } + + impl ::std::convert::From<&Self> for NetworkInterfaceAttachmentState { + fn from(value: &NetworkInterfaceAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From for NetworkInterfaceAttachmentState { + fn from(value: Slot) -> Self { + Self::Attached(value) + } + } + + ///`NetworkInterfaceRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name", + /// "slot" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// } + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + pub struct NetworkInterfaceRequest { + pub name: ::std::string::String, + pub slot: Slot, + } + + impl ::std::convert::From<&NetworkInterfaceRequest> for NetworkInterfaceRequest { + fn from(value: &NetworkInterfaceRequest) -> Self { + value.clone() + } + } + + impl NetworkInterfaceRequest { + pub fn builder() -> builder::NetworkInterfaceRequest { + Default::default() + } + } + + ///A stable index which is translated by Propolis into a PCI BDF, visible + /// to the guest. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A stable index which is translated by Propolis into a + /// PCI BDF, visible to the guest.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(transparent)] + pub struct Slot(pub u8); + impl ::std::ops::Deref for Slot { + type Target = u8; + fn deref(&self) -> &u8 { + &self.0 + } + } + + impl ::std::convert::From for u8 { + fn from(value: Slot) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Slot> for Slot { + fn from(value: &Slot) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Slot { + fn from(value: u8) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for Slot { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for Slot { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for Slot { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for Slot { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for Slot { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///`VolumeConstructionRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "sub_volumes", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "read_only_parent": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/VolumeConstructionRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "sub_volumes": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "volume" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "type", + /// "url" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "gen", + /// "opts", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "opts": { + /// "$ref": "#/components/schemas/CrucibleOpts" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "region" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "path", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "file" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, schemars :: JsonSchema, + )] + #[serde(tag = "type")] + pub enum VolumeConstructionRequest { + #[serde(rename = "volume")] + Volume { + block_size: u64, + id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + read_only_parent: ::std::option::Option<::std::boxed::Box>, + sub_volumes: ::std::vec::Vec, + }, + #[serde(rename = "url")] + Url { + block_size: u64, + id: ::uuid::Uuid, + url: ::std::string::String, + }, + #[serde(rename = "region")] + Region { + block_size: u64, + gen: u64, + opts: CrucibleOpts, + }, + #[serde(rename = "file")] + File { + block_size: u64, + id: ::uuid::Uuid, + path: ::std::string::String, + }, + } + + impl ::std::convert::From<&Self> for VolumeConstructionRequest { + fn from(value: &VolumeConstructionRequest) -> Self { + value.clone() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct CrucibleOpts { + cert_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + control: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + flush_timeout: ::std::result::Result<::std::option::Option, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + key: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + key_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + lossy: ::std::result::Result, + read_only: ::std::result::Result, + root_cert_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + target: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for CrucibleOpts { + fn default() -> Self { + Self { + cert_pem: Ok(Default::default()), + control: Ok(Default::default()), + flush_timeout: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + key: Ok(Default::default()), + key_pem: Ok(Default::default()), + lossy: Err("no value supplied for lossy".to_string()), + read_only: Err("no value supplied for read_only".to_string()), + root_cert_pem: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl CrucibleOpts { + pub fn cert_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.cert_pem = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert_pem: {}", e)); + self + } + pub fn control(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.control = value + .try_into() + .map_err(|e| format!("error converting supplied value for control: {}", e)); + self + } + pub fn flush_timeout(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.flush_timeout = value.try_into().map_err(|e| { + format!("error converting supplied value for flush_timeout: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn key_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.key_pem = value + .try_into() + .map_err(|e| format!("error converting supplied value for key_pem: {}", e)); + self + } + pub fn lossy(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.lossy = value + .try_into() + .map_err(|e| format!("error converting supplied value for lossy: {}", e)); + self + } + pub fn read_only(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.read_only = value + .try_into() + .map_err(|e| format!("error converting supplied value for read_only: {}", e)); + self + } + pub fn root_cert_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.root_cert_pem = value.try_into().map_err(|e| { + format!("error converting supplied value for root_cert_pem: {}", e) + }); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CrucibleOpts { + type Error = super::error::ConversionError; + fn try_from( + value: CrucibleOpts, + ) -> ::std::result::Result { + Ok(Self { + cert_pem: value.cert_pem?, + control: value.control?, + flush_timeout: value.flush_timeout?, + id: value.id?, + key: value.key?, + key_pem: value.key_pem?, + lossy: value.lossy?, + read_only: value.read_only?, + root_cert_pem: value.root_cert_pem?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for CrucibleOpts { + fn from(value: super::CrucibleOpts) -> Self { + Self { + cert_pem: Ok(value.cert_pem), + control: Ok(value.control), + flush_timeout: Ok(value.flush_timeout), + id: Ok(value.id), + key: Ok(value.key), + key_pem: Ok(value.key_pem), + lossy: Ok(value.lossy), + read_only: Ok(value.read_only), + root_cert_pem: Ok(value.root_cert_pem), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskAttachment { + disk_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + generation_id: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for DiskAttachment { + fn default() -> Self { + Self { + disk_id: Err("no value supplied for disk_id".to_string()), + generation_id: Err("no value supplied for generation_id".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl DiskAttachment { + pub fn disk_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.disk_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_id: {}", e)); + self + } + pub fn generation_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.generation_id = value.try_into().map_err(|e| { + format!("error converting supplied value for generation_id: {}", e) + }); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskAttachment { + type Error = super::error::ConversionError; + fn try_from( + value: DiskAttachment, + ) -> ::std::result::Result { + Ok(Self { + disk_id: value.disk_id?, + generation_id: value.generation_id?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for DiskAttachment { + fn from(value: super::DiskAttachment) -> Self { + Self { + disk_id: Ok(value.disk_id), + generation_id: Ok(value.generation_id), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskRequest { + device: ::std::result::Result<::std::string::String, ::std::string::String>, + gen: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + read_only: ::std::result::Result, + slot: ::std::result::Result, + volume_construction_request: + ::std::result::Result, + } + + impl ::std::default::Default for DiskRequest { + fn default() -> Self { + Self { + device: Err("no value supplied for device".to_string()), + gen: Err("no value supplied for gen".to_string()), + name: Err("no value supplied for name".to_string()), + read_only: Err("no value supplied for read_only".to_string()), + slot: Err("no value supplied for slot".to_string()), + volume_construction_request: Err("no value supplied for \ + volume_construction_request" + .to_string()), + } + } + } + + impl DiskRequest { + pub fn device(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device = value + .try_into() + .map_err(|e| format!("error converting supplied value for device: {}", e)); + self + } + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn read_only(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.read_only = value + .try_into() + .map_err(|e| format!("error converting supplied value for read_only: {}", e)); + self + } + pub fn slot(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.slot = value + .try_into() + .map_err(|e| format!("error converting supplied value for slot: {}", e)); + self + } + pub fn volume_construction_request(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.volume_construction_request = value.try_into().map_err(|e| { + format!( + "error converting supplied value for volume_construction_request: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::DiskRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DiskRequest, + ) -> ::std::result::Result { + Ok(Self { + device: value.device?, + gen: value.gen?, + name: value.name?, + read_only: value.read_only?, + slot: value.slot?, + volume_construction_request: value.volume_construction_request?, + }) + } + } + + impl ::std::convert::From for DiskRequest { + fn from(value: super::DiskRequest) -> Self { + Self { + device: Ok(value.device), + gen: Ok(value.gen), + name: Ok(value.name), + read_only: Ok(value.read_only), + slot: Ok(value.slot), + volume_construction_request: Ok(value.volume_construction_request), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + message: ::std::result::Result<::std::string::String, ::std::string::String>, + request_id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Error { + type Error = super::error::ConversionError; + fn try_from( + value: Error, + ) -> ::std::result::Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl ::std::convert::From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct Instance { + disks: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + nics: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + properties: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for Instance { + fn default() -> Self { + Self { + disks: Err("no value supplied for disks".to_string()), + nics: Err("no value supplied for nics".to_string()), + properties: Err("no value supplied for properties".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Instance { + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn nics(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.nics = value + .try_into() + .map_err(|e| format!("error converting supplied value for nics: {}", e)); + self + } + pub fn properties(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.properties = value + .try_into() + .map_err(|e| format!("error converting supplied value for properties: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Instance { + type Error = super::error::ConversionError; + fn try_from( + value: Instance, + ) -> ::std::result::Result { + Ok(Self { + disks: value.disks?, + nics: value.nics?, + properties: value.properties?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Instance { + fn from(value: super::Instance) -> Self { + Self { + disks: Ok(value.disks), + nics: Ok(value.nics), + properties: Ok(value.properties), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceEnsureRequest { + cloud_init_bytes: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + disks: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + migrate: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + nics: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + properties: ::std::result::Result, + } + + impl ::std::default::Default for InstanceEnsureRequest { + fn default() -> Self { + Self { + cloud_init_bytes: Ok(Default::default()), + disks: Ok(Default::default()), + migrate: Ok(Default::default()), + nics: Ok(Default::default()), + properties: Err("no value supplied for properties".to_string()), + } + } + } + + impl InstanceEnsureRequest { + pub fn cloud_init_bytes(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.cloud_init_bytes = value.try_into().map_err(|e| { + format!( + "error converting supplied value for cloud_init_bytes: {}", + e + ) + }); + self + } + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn migrate(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option, + >, + T::Error: ::std::fmt::Display, + { + self.migrate = value + .try_into() + .map_err(|e| format!("error converting supplied value for migrate: {}", e)); + self + } + pub fn nics(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.nics = value + .try_into() + .map_err(|e| format!("error converting supplied value for nics: {}", e)); + self + } + pub fn properties(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.properties = value + .try_into() + .map_err(|e| format!("error converting supplied value for properties: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceEnsureRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureRequest, + ) -> ::std::result::Result { + Ok(Self { + cloud_init_bytes: value.cloud_init_bytes?, + disks: value.disks?, + migrate: value.migrate?, + nics: value.nics?, + properties: value.properties?, + }) + } + } + + impl ::std::convert::From for InstanceEnsureRequest { + fn from(value: super::InstanceEnsureRequest) -> Self { + Self { + cloud_init_bytes: Ok(value.cloud_init_bytes), + disks: Ok(value.disks), + migrate: Ok(value.migrate), + nics: Ok(value.nics), + properties: Ok(value.properties), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceEnsureResponse { + migrate: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + } + + impl ::std::default::Default for InstanceEnsureResponse { + fn default() -> Self { + Self { + migrate: Ok(Default::default()), + } + } + } + + impl InstanceEnsureResponse { + pub fn migrate(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option, + >, + T::Error: ::std::fmt::Display, + { + self.migrate = value + .try_into() + .map_err(|e| format!("error converting supplied value for migrate: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceEnsureResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureResponse, + ) -> ::std::result::Result { + Ok(Self { + migrate: value.migrate?, + }) + } + } + + impl ::std::convert::From for InstanceEnsureResponse { + fn from(value: super::InstanceEnsureResponse) -> Self { + Self { + migrate: Ok(value.migrate), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceGetResponse { + instance: ::std::result::Result, + } + + impl ::std::default::Default for InstanceGetResponse { + fn default() -> Self { + Self { + instance: Err("no value supplied for instance".to_string()), + } + } + } + + impl InstanceGetResponse { + pub fn instance(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.instance = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceGetResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceGetResponse, + ) -> ::std::result::Result { + Ok(Self { + instance: value.instance?, + }) + } + } + + impl ::std::convert::From for InstanceGetResponse { + fn from(value: super::InstanceGetResponse) -> Self { + Self { + instance: Ok(value.instance), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateInitiateRequest { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + src_addr: ::std::result::Result<::std::string::String, ::std::string::String>, + src_uuid: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateInitiateRequest { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + src_addr: Err("no value supplied for src_addr".to_string()), + src_uuid: Err("no value supplied for src_uuid".to_string()), + } + } + } + + impl InstanceMigrateInitiateRequest { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + pub fn src_addr(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.src_addr = value + .try_into() + .map_err(|e| format!("error converting supplied value for src_addr: {}", e)); + self + } + pub fn src_uuid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.src_uuid = value + .try_into() + .map_err(|e| format!("error converting supplied value for src_uuid: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateInitiateRequest + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateRequest, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + src_addr: value.src_addr?, + src_uuid: value.src_uuid?, + }) + } + } + + impl ::std::convert::From + for InstanceMigrateInitiateRequest + { + fn from(value: super::InstanceMigrateInitiateRequest) -> Self { + Self { + migration_id: Ok(value.migration_id), + src_addr: Ok(value.src_addr), + src_uuid: Ok(value.src_uuid), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateInitiateResponse { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateInitiateResponse { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + } + } + } + + impl InstanceMigrateInitiateResponse { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateInitiateResponse + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateResponse, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + }) + } + } + + impl ::std::convert::From + for InstanceMigrateInitiateResponse + { + fn from(value: super::InstanceMigrateInitiateResponse) -> Self { + Self { + migration_id: Ok(value.migration_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateStatusRequest { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateStatusRequest { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + } + } + } + + impl InstanceMigrateStatusRequest { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceMigrateStatusRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusRequest, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + }) + } + } + + impl ::std::convert::From for InstanceMigrateStatusRequest { + fn from(value: super::InstanceMigrateStatusRequest) -> Self { + Self { + migration_id: Ok(value.migration_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateStatusResponse { + state: ::std::result::Result, + } + + impl ::std::default::Default for InstanceMigrateStatusResponse { + fn default() -> Self { + Self { + state: Err("no value supplied for state".to_string()), + } + } + } + + impl InstanceMigrateStatusResponse { + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateStatusResponse + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusResponse, + ) -> ::std::result::Result { + Ok(Self { + state: value.state?, + }) + } + } + + impl ::std::convert::From for InstanceMigrateStatusResponse { + fn from(value: super::InstanceMigrateStatusResponse) -> Self { + Self { + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceProperties { + bootrom_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + image_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + vcpus: ::std::result::Result, + } + + impl ::std::default::Default for InstanceProperties { + fn default() -> Self { + Self { + bootrom_id: Err("no value supplied for bootrom_id".to_string()), + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + image_id: Err("no value supplied for image_id".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + vcpus: Err("no value supplied for vcpus".to_string()), + } + } + } + + impl InstanceProperties { + pub fn bootrom_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.bootrom_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootrom_id: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn image_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.image_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for image_id: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn vcpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.vcpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for vcpus: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceProperties { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceProperties, + ) -> ::std::result::Result { + Ok(Self { + bootrom_id: value.bootrom_id?, + description: value.description?, + id: value.id?, + image_id: value.image_id?, + memory: value.memory?, + name: value.name?, + vcpus: value.vcpus?, + }) + } + } + + impl ::std::convert::From for InstanceProperties { + fn from(value: super::InstanceProperties) -> Self { + Self { + bootrom_id: Ok(value.bootrom_id), + description: Ok(value.description), + id: Ok(value.id), + image_id: Ok(value.image_id), + memory: Ok(value.memory), + name: Ok(value.name), + vcpus: Ok(value.vcpus), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceStateMonitorRequest { + gen: ::std::result::Result, + } + + impl ::std::default::Default for InstanceStateMonitorRequest { + fn default() -> Self { + Self { + gen: Err("no value supplied for gen".to_string()), + } + } + } + + impl InstanceStateMonitorRequest { + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceStateMonitorRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorRequest, + ) -> ::std::result::Result { + Ok(Self { gen: value.gen? }) + } + } + + impl ::std::convert::From for InstanceStateMonitorRequest { + fn from(value: super::InstanceStateMonitorRequest) -> Self { + Self { gen: Ok(value.gen) } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceStateMonitorResponse { + gen: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for InstanceStateMonitorResponse { + fn default() -> Self { + Self { + gen: Err("no value supplied for gen".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl InstanceStateMonitorResponse { + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceStateMonitorResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorResponse, + ) -> ::std::result::Result { + Ok(Self { + gen: value.gen?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for InstanceStateMonitorResponse { + fn from(value: super::InstanceStateMonitorResponse) -> Self { + Self { + gen: Ok(value.gen), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterface { + attachment: ::std::result::Result< + super::NetworkInterfaceAttachmentState, + ::std::string::String, + >, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for NetworkInterface { + fn default() -> Self { + Self { + attachment: Err("no value supplied for attachment".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl NetworkInterface { + pub fn attachment(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.attachment = value + .try_into() + .map_err(|e| format!("error converting supplied value for attachment: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterface { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterface, + ) -> ::std::result::Result { + Ok(Self { + attachment: value.attachment?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for NetworkInterface { + fn from(value: super::NetworkInterface) -> Self { + Self { + attachment: Ok(value.attachment), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceRequest { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + slot: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceRequest { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + slot: Err("no value supplied for slot".to_string()), + } + } + } + + impl NetworkInterfaceRequest { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn slot(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.slot = value + .try_into() + .map_err(|e| format!("error converting supplied value for slot: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceRequest { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceRequest, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + slot: value.slot?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceRequest { + fn from(value: super::NetworkInterfaceRequest) -> Self { + Self { + name: Ok(value.name), + slot: Ok(value.slot), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `GET` request to `/instance` + /// + ///```ignore + /// let response = client.instance_get() + /// .send() + /// .await; + /// ``` + pub fn instance_get(&self) -> builder::InstanceGet<'_> { + builder::InstanceGet::new(self) + } + + ///Sends a `PUT` request to `/instance` + /// + ///```ignore + /// let response = client.instance_ensure() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_ensure(&self) -> builder::InstanceEnsure<'_> { + builder::InstanceEnsure::new(self) + } + + ///Issue a snapshot request to a crucible backend + /// + ///Sends a `POST` request to `/instance/disk/{id}/snapshot/{snapshot_id}` + /// + ///```ignore + /// let response = client.instance_issue_crucible_snapshot_request() + /// .id(id) + /// .snapshot_id(snapshot_id) + /// .send() + /// .await; + /// ``` + pub fn instance_issue_crucible_snapshot_request( + &self, + ) -> builder::InstanceIssueCrucibleSnapshotRequest<'_> { + builder::InstanceIssueCrucibleSnapshotRequest::new(self) + } + + ///Sends a `GET` request to `/instance/migrate/status` + /// + ///```ignore + /// let response = client.instance_migrate_status() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_migrate_status(&self) -> builder::InstanceMigrateStatus<'_> { + builder::InstanceMigrateStatus::new(self) + } + + ///Sends a `GET` request to `/instance/serial` + /// + ///```ignore + /// let response = client.instance_serial() + /// .send() + /// .await; + /// ``` + pub fn instance_serial(&self) -> builder::InstanceSerial<'_> { + builder::InstanceSerial::new(self) + } + + ///Sends a `PUT` request to `/instance/state` + /// + ///```ignore + /// let response = client.instance_state_put() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_state_put(&self) -> builder::InstanceStatePut<'_> { + builder::InstanceStatePut::new(self) + } + + ///Sends a `GET` request to `/instance/state-monitor` + /// + ///```ignore + /// let response = client.instance_state_monitor() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_state_monitor(&self) -> builder::InstanceStateMonitor<'_> { + builder::InstanceStateMonitor::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::instance_get`] + /// + ///[`Client::instance_get`]: super::Client::instance_get + #[derive(Debug, Clone)] + pub struct InstanceGet<'a> { + client: &'a super::Client, + } + + impl<'a> InstanceGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/instance` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/instance", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_ensure`] + /// + ///[`Client::instance_ensure`]: super::Client::instance_ensure + #[derive(Debug, Clone)] + pub struct InstanceEnsure<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceEnsure<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceEnsureRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceEnsureRequest, + ) -> types::builder::InstanceEnsureRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/instance` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_ensure", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_issue_crucible_snapshot_request`] + /// + ///[`Client::instance_issue_crucible_snapshot_request`]: super::Client::instance_issue_crucible_snapshot_request + #[derive(Debug, Clone)] + pub struct InstanceIssueCrucibleSnapshotRequest<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + snapshot_id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceIssueCrucibleSnapshotRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + snapshot_id: Err("snapshot_id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn snapshot_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.snapshot_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for snapshot_id failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/instance/disk/{id}/snapshot/{snapshot_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + id, + snapshot_id, + } = self; + let id = id.map_err(Error::InvalidRequest)?; + let snapshot_id = snapshot_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/instance/disk/{}/snapshot/{}", + client.baseurl, + encode_path(&id.to_string()), + encode_path(&snapshot_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_issue_crucible_snapshot_request", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_migrate_status`] + /// + ///[`Client::instance_migrate_status`]: super::Client::instance_migrate_status + #[derive(Debug, Clone)] + pub struct InstanceMigrateStatus<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceMigrateStatus<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceMigrateStatusRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceMigrateStatusRequest, + ) -> types::builder::InstanceMigrateStatusRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/instance/migrate/status` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::InstanceMigrateStatusRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/migrate/status", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_status", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial`] + /// + ///[`Client::instance_serial`]: super::Client::instance_serial + #[derive(Debug, Clone)] + pub struct InstanceSerial<'a> { + client: &'a super::Client, + } + + impl<'a> InstanceSerial<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/instance/serial` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/instance/serial", client.baseurl,); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`Client::instance_state_put`] + /// + ///[`Client::instance_state_put`]: super::Client::instance_state_put + #[derive(Debug, Clone)] + pub struct InstanceStatePut<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceStatePut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceStateRequested` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/instance/state` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/state", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_put", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_state_monitor`] + /// + ///[`Client::instance_state_monitor`]: super::Client::instance_state_monitor + #[derive(Debug, Clone)] + pub struct InstanceStateMonitor<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceStateMonitor<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceStateMonitorRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceStateMonitorRequest, + ) -> types::builder::InstanceStateMonitorRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/instance/state-monitor` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::InstanceStateMonitorRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/state-monitor", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_monitor", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + pub use self::super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder_tagged.rs b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder_tagged.rs new file mode 100644 index 00000000..678ceea7 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_builder_tagged.rs @@ -0,0 +1,3505 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`CrucibleOpts` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "lossy", + /// "read_only", + /// "target" + /// ], + /// "properties": { + /// "cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "control": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "flush_timeout": { + /// "type": [ + /// "integer", + /// "null" + /// ], + /// "format": "uint32", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "key": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "key_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "lossy": { + /// "type": "boolean" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "root_cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "target": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CrucibleOpts { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cert_pem: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub control: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub flush_timeout: ::std::option::Option, + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key_pem: ::std::option::Option<::std::string::String>, + pub lossy: bool, + pub read_only: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub root_cert_pem: ::std::option::Option<::std::string::String>, + pub target: ::std::vec::Vec<::std::string::String>, + } + + impl ::std::convert::From<&CrucibleOpts> for CrucibleOpts { + fn from(value: &CrucibleOpts) -> Self { + value.clone() + } + } + + impl CrucibleOpts { + pub fn builder() -> builder::CrucibleOpts { + Default::default() + } + } + + ///`DiskAttachment` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk_id", + /// "generation_id", + /// "state" + /// ], + /// "properties": { + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "generation_id": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskAttachmentState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskAttachment { + pub disk_id: ::uuid::Uuid, + pub generation_id: u64, + pub state: DiskAttachmentState, + } + + impl ::std::convert::From<&DiskAttachment> for DiskAttachment { + fn from(value: &DiskAttachment) -> Self { + value.clone() + } + } + + impl DiskAttachment { + pub fn builder() -> builder::DiskAttachment { + Default::default() + } + } + + ///`DiskAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Destroyed", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "type": "string", + /// "format": "uuid" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub enum DiskAttachmentState { + Detached, + Destroyed, + Faulted, + Attached(::uuid::Uuid), + } + + impl ::std::convert::From<&Self> for DiskAttachmentState { + fn from(value: &DiskAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::uuid::Uuid> for DiskAttachmentState { + fn from(value: ::uuid::Uuid) -> Self { + Self::Attached(value) + } + } + + ///`DiskRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "device", + /// "gen", + /// "name", + /// "read_only", + /// "slot", + /// "volume_construction_request" + /// ], + /// "properties": { + /// "device": { + /// "type": "string" + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// }, + /// "volume_construction_request": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskRequest { + pub device: ::std::string::String, + pub gen: u64, + pub name: ::std::string::String, + pub read_only: bool, + pub slot: Slot, + pub volume_construction_request: VolumeConstructionRequest, + } + + impl ::std::convert::From<&DiskRequest> for DiskRequest { + fn from(value: &DiskRequest) -> Self { + value.clone() + } + } + + impl DiskRequest { + pub fn builder() -> builder::DiskRequest { + Default::default() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + impl Error { + pub fn builder() -> builder::Error { + Default::default() + } + } + + ///`Instance` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disks", + /// "nics", + /// "properties", + /// "state" + /// ], + /// "properties": { + /// "disks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskAttachment" + /// } + /// }, + /// "nics": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Instance { + pub disks: ::std::vec::Vec, + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + pub state: InstanceState, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + impl Instance { + pub fn builder() -> builder::Instance { + Default::default() + } + } + + ///`InstanceEnsureRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "properties" + /// ], + /// "properties": { + /// "cloud_init_bytes": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "disks": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskRequest" + /// } + /// }, + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "nics": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceRequest" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceEnsureRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cloud_init_bytes: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + } + + impl ::std::convert::From<&InstanceEnsureRequest> for InstanceEnsureRequest { + fn from(value: &InstanceEnsureRequest) -> Self { + value.clone() + } + } + + impl InstanceEnsureRequest { + pub fn builder() -> builder::InstanceEnsureRequest { + Default::default() + } + } + + ///`InstanceEnsureResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "properties": { + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateResponse" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceEnsureResponse { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + } + + impl ::std::convert::From<&InstanceEnsureResponse> for InstanceEnsureResponse { + fn from(value: &InstanceEnsureResponse) -> Self { + value.clone() + } + } + + impl ::std::default::Default for InstanceEnsureResponse { + fn default() -> Self { + Self { + migrate: Default::default(), + } + } + } + + impl InstanceEnsureResponse { + pub fn builder() -> builder::InstanceEnsureResponse { + Default::default() + } + } + + ///`InstanceGetResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "instance" + /// ], + /// "properties": { + /// "instance": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceGetResponse { + pub instance: Instance, + } + + impl ::std::convert::From<&InstanceGetResponse> for InstanceGetResponse { + fn from(value: &InstanceGetResponse) -> Self { + value.clone() + } + } + + impl InstanceGetResponse { + pub fn builder() -> builder::InstanceGetResponse { + Default::default() + } + } + + ///`InstanceMigrateInitiateRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id", + /// "src_addr", + /// "src_uuid" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "src_addr": { + /// "type": "string" + /// }, + /// "src_uuid": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateInitiateRequest { + pub migration_id: ::uuid::Uuid, + pub src_addr: ::std::string::String, + pub src_uuid: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateRequest> for InstanceMigrateInitiateRequest { + fn from(value: &InstanceMigrateInitiateRequest) -> Self { + value.clone() + } + } + + impl InstanceMigrateInitiateRequest { + pub fn builder() -> builder::InstanceMigrateInitiateRequest { + Default::default() + } + } + + ///`InstanceMigrateInitiateResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateInitiateResponse { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateResponse> for InstanceMigrateInitiateResponse { + fn from(value: &InstanceMigrateInitiateResponse) -> Self { + value.clone() + } + } + + impl InstanceMigrateInitiateResponse { + pub fn builder() -> builder::InstanceMigrateInitiateResponse { + Default::default() + } + } + + ///`InstanceMigrateStatusRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateStatusRequest { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateStatusRequest> for InstanceMigrateStatusRequest { + fn from(value: &InstanceMigrateStatusRequest) -> Self { + value.clone() + } + } + + impl InstanceMigrateStatusRequest { + pub fn builder() -> builder::InstanceMigrateStatusRequest { + Default::default() + } + } + + ///`InstanceMigrateStatusResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "$ref": "#/components/schemas/MigrationState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateStatusResponse { + pub state: MigrationState, + } + + impl ::std::convert::From<&InstanceMigrateStatusResponse> for InstanceMigrateStatusResponse { + fn from(value: &InstanceMigrateStatusResponse) -> Self { + value.clone() + } + } + + impl InstanceMigrateStatusResponse { + pub fn builder() -> builder::InstanceMigrateStatusResponse { + Default::default() + } + } + + ///`InstanceProperties` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootrom_id", + /// "description", + /// "id", + /// "image_id", + /// "memory", + /// "name", + /// "vcpus" + /// ], + /// "properties": { + /// "bootrom_id": { + /// "description": "ID of the bootrom used to initialize this + /// Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "description": { + /// "description": "Free-form text description of an Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "Unique identifier for this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "description": "ID of the image used to initialize this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "Size of memory allocated to the Instance, in MiB.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "description": "Human-readable name of the Instance.", + /// "type": "string" + /// }, + /// "vcpus": { + /// "description": "Number of vCPUs to be allocated to the Instance.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceProperties { + ///ID of the bootrom used to initialize this Instance. + pub bootrom_id: ::uuid::Uuid, + ///Free-form text description of an Instance. + pub description: ::std::string::String, + ///Unique identifier for this Instance. + pub id: ::uuid::Uuid, + ///ID of the image used to initialize this Instance. + pub image_id: ::uuid::Uuid, + ///Size of memory allocated to the Instance, in MiB. + pub memory: u64, + ///Human-readable name of the Instance. + pub name: ::std::string::String, + ///Number of vCPUs to be allocated to the Instance. + pub vcpus: u8, + } + + impl ::std::convert::From<&InstanceProperties> for InstanceProperties { + fn from(value: &InstanceProperties) -> Self { + value.clone() + } + } + + impl InstanceProperties { + pub fn builder() -> builder::InstanceProperties { + Default::default() + } + } + + ///Current state of an Instance. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Current state of an Instance.", + /// "type": "string", + /// "enum": [ + /// "Creating", + /// "Starting", + /// "Running", + /// "Stopping", + /// "Stopped", + /// "Rebooting", + /// "Migrating", + /// "Repairing", + /// "Failed", + /// "Destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceState { + Creating, + Starting, + Running, + Stopping, + Stopped, + Rebooting, + Migrating, + Repairing, + Failed, + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("Creating"), + Self::Starting => f.write_str("Starting"), + Self::Running => f.write_str("Running"), + Self::Stopping => f.write_str("Stopping"), + Self::Stopped => f.write_str("Stopped"), + Self::Rebooting => f.write_str("Rebooting"), + Self::Migrating => f.write_str("Migrating"), + Self::Repairing => f.write_str("Repairing"), + Self::Failed => f.write_str("Failed"), + Self::Destroyed => f.write_str("Destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Creating" => Ok(Self::Creating), + "Starting" => Ok(Self::Starting), + "Running" => Ok(Self::Running), + "Stopping" => Ok(Self::Stopping), + "Stopped" => Ok(Self::Stopped), + "Rebooting" => Ok(Self::Rebooting), + "Migrating" => Ok(Self::Migrating), + "Repairing" => Ok(Self::Repairing), + "Failed" => Ok(Self::Failed), + "Destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`InstanceStateMonitorRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceStateMonitorRequest { + pub gen: u64, + } + + impl ::std::convert::From<&InstanceStateMonitorRequest> for InstanceStateMonitorRequest { + fn from(value: &InstanceStateMonitorRequest) -> Self { + value.clone() + } + } + + impl InstanceStateMonitorRequest { + pub fn builder() -> builder::InstanceStateMonitorRequest { + Default::default() + } + } + + ///`InstanceStateMonitorResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen", + /// "state" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceStateMonitorResponse { + pub gen: u64, + pub state: InstanceState, + } + + impl ::std::convert::From<&InstanceStateMonitorResponse> for InstanceStateMonitorResponse { + fn from(value: &InstanceStateMonitorResponse) -> Self { + value.clone() + } + } + + impl InstanceStateMonitorResponse { + pub fn builder() -> builder::InstanceStateMonitorResponse { + Default::default() + } + } + + ///`InstanceStateRequested` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Run", + /// "Stop", + /// "Reboot", + /// "MigrateStart" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceStateRequested { + Run, + Stop, + Reboot, + MigrateStart, + } + + impl ::std::convert::From<&Self> for InstanceStateRequested { + fn from(value: &InstanceStateRequested) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceStateRequested { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Run => f.write_str("Run"), + Self::Stop => f.write_str("Stop"), + Self::Reboot => f.write_str("Reboot"), + Self::MigrateStart => f.write_str("MigrateStart"), + } + } + } + + impl ::std::str::FromStr for InstanceStateRequested { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Run" => Ok(Self::Run), + "Stop" => Ok(Self::Stop), + "Reboot" => Ok(Self::Reboot), + "MigrateStart" => Ok(Self::MigrateStart), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`MigrationState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Sync", + /// "RamPush", + /// "Pause", + /// "RamPushDirty", + /// "Device", + /// "Arch", + /// "Resume", + /// "RamPull", + /// "Finish", + /// "Error" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum MigrationState { + Sync, + RamPush, + Pause, + RamPushDirty, + Device, + Arch, + Resume, + RamPull, + Finish, + Error, + } + + impl ::std::convert::From<&Self> for MigrationState { + fn from(value: &MigrationState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for MigrationState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Sync => f.write_str("Sync"), + Self::RamPush => f.write_str("RamPush"), + Self::Pause => f.write_str("Pause"), + Self::RamPushDirty => f.write_str("RamPushDirty"), + Self::Device => f.write_str("Device"), + Self::Arch => f.write_str("Arch"), + Self::Resume => f.write_str("Resume"), + Self::RamPull => f.write_str("RamPull"), + Self::Finish => f.write_str("Finish"), + Self::Error => f.write_str("Error"), + } + } + } + + impl ::std::str::FromStr for MigrationState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Sync" => Ok(Self::Sync), + "RamPush" => Ok(Self::RamPush), + "Pause" => Ok(Self::Pause), + "RamPushDirty" => Ok(Self::RamPushDirty), + "Device" => Ok(Self::Device), + "Arch" => Ok(Self::Arch), + "Resume" => Ok(Self::Resume), + "RamPull" => Ok(Self::RamPull), + "Finish" => Ok(Self::Finish), + "Error" => Ok(Self::Error), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for MigrationState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`NetworkInterface` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "attachment", + /// "name" + /// ], + /// "properties": { + /// "attachment": { + /// "$ref": "#/components/schemas/NetworkInterfaceAttachmentState" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterface { + pub attachment: NetworkInterfaceAttachmentState, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + impl NetworkInterface { + pub fn builder() -> builder::NetworkInterface { + Default::default() + } + } + + ///`NetworkInterfaceAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub enum NetworkInterfaceAttachmentState { + Detached, + Faulted, + Attached(Slot), + } + + impl ::std::convert::From<&Self> for NetworkInterfaceAttachmentState { + fn from(value: &NetworkInterfaceAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From for NetworkInterfaceAttachmentState { + fn from(value: Slot) -> Self { + Self::Attached(value) + } + } + + ///`NetworkInterfaceRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name", + /// "slot" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceRequest { + pub name: ::std::string::String, + pub slot: Slot, + } + + impl ::std::convert::From<&NetworkInterfaceRequest> for NetworkInterfaceRequest { + fn from(value: &NetworkInterfaceRequest) -> Self { + value.clone() + } + } + + impl NetworkInterfaceRequest { + pub fn builder() -> builder::NetworkInterfaceRequest { + Default::default() + } + } + + ///A stable index which is translated by Propolis into a PCI BDF, visible + /// to the guest. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A stable index which is translated by Propolis into a + /// PCI BDF, visible to the guest.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct Slot(pub u8); + impl ::std::ops::Deref for Slot { + type Target = u8; + fn deref(&self) -> &u8 { + &self.0 + } + } + + impl ::std::convert::From for u8 { + fn from(value: Slot) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Slot> for Slot { + fn from(value: &Slot) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Slot { + fn from(value: u8) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for Slot { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for Slot { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for Slot { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for Slot { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for Slot { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///`VolumeConstructionRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "sub_volumes", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "read_only_parent": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/VolumeConstructionRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "sub_volumes": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "volume" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "type", + /// "url" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "gen", + /// "opts", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "opts": { + /// "$ref": "#/components/schemas/CrucibleOpts" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "region" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "path", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "file" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum VolumeConstructionRequest { + #[serde(rename = "volume")] + Volume { + block_size: u64, + id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + read_only_parent: ::std::option::Option<::std::boxed::Box>, + sub_volumes: ::std::vec::Vec, + }, + #[serde(rename = "url")] + Url { + block_size: u64, + id: ::uuid::Uuid, + url: ::std::string::String, + }, + #[serde(rename = "region")] + Region { + block_size: u64, + gen: u64, + opts: CrucibleOpts, + }, + #[serde(rename = "file")] + File { + block_size: u64, + id: ::uuid::Uuid, + path: ::std::string::String, + }, + } + + impl ::std::convert::From<&Self> for VolumeConstructionRequest { + fn from(value: &VolumeConstructionRequest) -> Self { + value.clone() + } + } + + /// Types for composing complex structures. + pub mod builder { + #[derive(Clone, Debug)] + pub struct CrucibleOpts { + cert_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + control: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + flush_timeout: ::std::result::Result<::std::option::Option, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + key: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + key_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + lossy: ::std::result::Result, + read_only: ::std::result::Result, + root_cert_pem: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + target: ::std::result::Result< + ::std::vec::Vec<::std::string::String>, + ::std::string::String, + >, + } + + impl ::std::default::Default for CrucibleOpts { + fn default() -> Self { + Self { + cert_pem: Ok(Default::default()), + control: Ok(Default::default()), + flush_timeout: Ok(Default::default()), + id: Err("no value supplied for id".to_string()), + key: Ok(Default::default()), + key_pem: Ok(Default::default()), + lossy: Err("no value supplied for lossy".to_string()), + read_only: Err("no value supplied for read_only".to_string()), + root_cert_pem: Ok(Default::default()), + target: Err("no value supplied for target".to_string()), + } + } + } + + impl CrucibleOpts { + pub fn cert_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.cert_pem = value + .try_into() + .map_err(|e| format!("error converting supplied value for cert_pem: {}", e)); + self + } + pub fn control(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.control = value + .try_into() + .map_err(|e| format!("error converting supplied value for control: {}", e)); + self + } + pub fn flush_timeout(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option>, + T::Error: ::std::fmt::Display, + { + self.flush_timeout = value.try_into().map_err(|e| { + format!("error converting supplied value for flush_timeout: {}", e) + }); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn key(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.key = value + .try_into() + .map_err(|e| format!("error converting supplied value for key: {}", e)); + self + } + pub fn key_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.key_pem = value + .try_into() + .map_err(|e| format!("error converting supplied value for key_pem: {}", e)); + self + } + pub fn lossy(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.lossy = value + .try_into() + .map_err(|e| format!("error converting supplied value for lossy: {}", e)); + self + } + pub fn read_only(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.read_only = value + .try_into() + .map_err(|e| format!("error converting supplied value for read_only: {}", e)); + self + } + pub fn root_cert_pem(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.root_cert_pem = value.try_into().map_err(|e| { + format!("error converting supplied value for root_cert_pem: {}", e) + }); + self + } + pub fn target(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.target = value + .try_into() + .map_err(|e| format!("error converting supplied value for target: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::CrucibleOpts { + type Error = super::error::ConversionError; + fn try_from( + value: CrucibleOpts, + ) -> ::std::result::Result { + Ok(Self { + cert_pem: value.cert_pem?, + control: value.control?, + flush_timeout: value.flush_timeout?, + id: value.id?, + key: value.key?, + key_pem: value.key_pem?, + lossy: value.lossy?, + read_only: value.read_only?, + root_cert_pem: value.root_cert_pem?, + target: value.target?, + }) + } + } + + impl ::std::convert::From for CrucibleOpts { + fn from(value: super::CrucibleOpts) -> Self { + Self { + cert_pem: Ok(value.cert_pem), + control: Ok(value.control), + flush_timeout: Ok(value.flush_timeout), + id: Ok(value.id), + key: Ok(value.key), + key_pem: Ok(value.key_pem), + lossy: Ok(value.lossy), + read_only: Ok(value.read_only), + root_cert_pem: Ok(value.root_cert_pem), + target: Ok(value.target), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskAttachment { + disk_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + generation_id: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for DiskAttachment { + fn default() -> Self { + Self { + disk_id: Err("no value supplied for disk_id".to_string()), + generation_id: Err("no value supplied for generation_id".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl DiskAttachment { + pub fn disk_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.disk_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for disk_id: {}", e)); + self + } + pub fn generation_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.generation_id = value.try_into().map_err(|e| { + format!("error converting supplied value for generation_id: {}", e) + }); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::DiskAttachment { + type Error = super::error::ConversionError; + fn try_from( + value: DiskAttachment, + ) -> ::std::result::Result { + Ok(Self { + disk_id: value.disk_id?, + generation_id: value.generation_id?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for DiskAttachment { + fn from(value: super::DiskAttachment) -> Self { + Self { + disk_id: Ok(value.disk_id), + generation_id: Ok(value.generation_id), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct DiskRequest { + device: ::std::result::Result<::std::string::String, ::std::string::String>, + gen: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + read_only: ::std::result::Result, + slot: ::std::result::Result, + volume_construction_request: + ::std::result::Result, + } + + impl ::std::default::Default for DiskRequest { + fn default() -> Self { + Self { + device: Err("no value supplied for device".to_string()), + gen: Err("no value supplied for gen".to_string()), + name: Err("no value supplied for name".to_string()), + read_only: Err("no value supplied for read_only".to_string()), + slot: Err("no value supplied for slot".to_string()), + volume_construction_request: Err("no value supplied for \ + volume_construction_request" + .to_string()), + } + } + } + + impl DiskRequest { + pub fn device(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.device = value + .try_into() + .map_err(|e| format!("error converting supplied value for device: {}", e)); + self + } + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn read_only(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.read_only = value + .try_into() + .map_err(|e| format!("error converting supplied value for read_only: {}", e)); + self + } + pub fn slot(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.slot = value + .try_into() + .map_err(|e| format!("error converting supplied value for slot: {}", e)); + self + } + pub fn volume_construction_request(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.volume_construction_request = value.try_into().map_err(|e| { + format!( + "error converting supplied value for volume_construction_request: {}", + e + ) + }); + self + } + } + + impl ::std::convert::TryFrom for super::DiskRequest { + type Error = super::error::ConversionError; + fn try_from( + value: DiskRequest, + ) -> ::std::result::Result { + Ok(Self { + device: value.device?, + gen: value.gen?, + name: value.name?, + read_only: value.read_only?, + slot: value.slot?, + volume_construction_request: value.volume_construction_request?, + }) + } + } + + impl ::std::convert::From for DiskRequest { + fn from(value: super::DiskRequest) -> Self { + Self { + device: Ok(value.device), + gen: Ok(value.gen), + name: Ok(value.name), + read_only: Ok(value.read_only), + slot: Ok(value.slot), + volume_construction_request: Ok(value.volume_construction_request), + } + } + } + + #[derive(Clone, Debug)] + pub struct Error { + error_code: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + message: ::std::result::Result<::std::string::String, ::std::string::String>, + request_id: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for Error { + fn default() -> Self { + Self { + error_code: Ok(Default::default()), + message: Err("no value supplied for message".to_string()), + request_id: Err("no value supplied for request_id".to_string()), + } + } + } + + impl Error { + pub fn error_code(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.error_code = value + .try_into() + .map_err(|e| format!("error converting supplied value for error_code: {}", e)); + self + } + pub fn message(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.message = value + .try_into() + .map_err(|e| format!("error converting supplied value for message: {}", e)); + self + } + pub fn request_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.request_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for request_id: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Error { + type Error = super::error::ConversionError; + fn try_from( + value: Error, + ) -> ::std::result::Result { + Ok(Self { + error_code: value.error_code?, + message: value.message?, + request_id: value.request_id?, + }) + } + } + + impl ::std::convert::From for Error { + fn from(value: super::Error) -> Self { + Self { + error_code: Ok(value.error_code), + message: Ok(value.message), + request_id: Ok(value.request_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct Instance { + disks: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + nics: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + properties: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for Instance { + fn default() -> Self { + Self { + disks: Err("no value supplied for disks".to_string()), + nics: Err("no value supplied for nics".to_string()), + properties: Err("no value supplied for properties".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl Instance { + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn nics(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.nics = value + .try_into() + .map_err(|e| format!("error converting supplied value for nics: {}", e)); + self + } + pub fn properties(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.properties = value + .try_into() + .map_err(|e| format!("error converting supplied value for properties: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::Instance { + type Error = super::error::ConversionError; + fn try_from( + value: Instance, + ) -> ::std::result::Result { + Ok(Self { + disks: value.disks?, + nics: value.nics?, + properties: value.properties?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for Instance { + fn from(value: super::Instance) -> Self { + Self { + disks: Ok(value.disks), + nics: Ok(value.nics), + properties: Ok(value.properties), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceEnsureRequest { + cloud_init_bytes: ::std::result::Result< + ::std::option::Option<::std::string::String>, + ::std::string::String, + >, + disks: + ::std::result::Result<::std::vec::Vec, ::std::string::String>, + migrate: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + nics: ::std::result::Result< + ::std::vec::Vec, + ::std::string::String, + >, + properties: ::std::result::Result, + } + + impl ::std::default::Default for InstanceEnsureRequest { + fn default() -> Self { + Self { + cloud_init_bytes: Ok(Default::default()), + disks: Ok(Default::default()), + migrate: Ok(Default::default()), + nics: Ok(Default::default()), + properties: Err("no value supplied for properties".to_string()), + } + } + } + + impl InstanceEnsureRequest { + pub fn cloud_init_bytes(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>, + T::Error: ::std::fmt::Display, + { + self.cloud_init_bytes = value.try_into().map_err(|e| { + format!( + "error converting supplied value for cloud_init_bytes: {}", + e + ) + }); + self + } + pub fn disks(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.disks = value + .try_into() + .map_err(|e| format!("error converting supplied value for disks: {}", e)); + self + } + pub fn migrate(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option, + >, + T::Error: ::std::fmt::Display, + { + self.migrate = value + .try_into() + .map_err(|e| format!("error converting supplied value for migrate: {}", e)); + self + } + pub fn nics(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::vec::Vec>, + T::Error: ::std::fmt::Display, + { + self.nics = value + .try_into() + .map_err(|e| format!("error converting supplied value for nics: {}", e)); + self + } + pub fn properties(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.properties = value + .try_into() + .map_err(|e| format!("error converting supplied value for properties: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceEnsureRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureRequest, + ) -> ::std::result::Result { + Ok(Self { + cloud_init_bytes: value.cloud_init_bytes?, + disks: value.disks?, + migrate: value.migrate?, + nics: value.nics?, + properties: value.properties?, + }) + } + } + + impl ::std::convert::From for InstanceEnsureRequest { + fn from(value: super::InstanceEnsureRequest) -> Self { + Self { + cloud_init_bytes: Ok(value.cloud_init_bytes), + disks: Ok(value.disks), + migrate: Ok(value.migrate), + nics: Ok(value.nics), + properties: Ok(value.properties), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceEnsureResponse { + migrate: ::std::result::Result< + ::std::option::Option, + ::std::string::String, + >, + } + + impl ::std::default::Default for InstanceEnsureResponse { + fn default() -> Self { + Self { + migrate: Ok(Default::default()), + } + } + } + + impl InstanceEnsureResponse { + pub fn migrate(mut self, value: T) -> Self + where + T: ::std::convert::TryInto< + ::std::option::Option, + >, + T::Error: ::std::fmt::Display, + { + self.migrate = value + .try_into() + .map_err(|e| format!("error converting supplied value for migrate: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceEnsureResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureResponse, + ) -> ::std::result::Result { + Ok(Self { + migrate: value.migrate?, + }) + } + } + + impl ::std::convert::From for InstanceEnsureResponse { + fn from(value: super::InstanceEnsureResponse) -> Self { + Self { + migrate: Ok(value.migrate), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceGetResponse { + instance: ::std::result::Result, + } + + impl ::std::default::Default for InstanceGetResponse { + fn default() -> Self { + Self { + instance: Err("no value supplied for instance".to_string()), + } + } + } + + impl InstanceGetResponse { + pub fn instance(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.instance = value + .try_into() + .map_err(|e| format!("error converting supplied value for instance: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceGetResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceGetResponse, + ) -> ::std::result::Result { + Ok(Self { + instance: value.instance?, + }) + } + } + + impl ::std::convert::From for InstanceGetResponse { + fn from(value: super::InstanceGetResponse) -> Self { + Self { + instance: Ok(value.instance), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateInitiateRequest { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + src_addr: ::std::result::Result<::std::string::String, ::std::string::String>, + src_uuid: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateInitiateRequest { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + src_addr: Err("no value supplied for src_addr".to_string()), + src_uuid: Err("no value supplied for src_uuid".to_string()), + } + } + } + + impl InstanceMigrateInitiateRequest { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + pub fn src_addr(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.src_addr = value + .try_into() + .map_err(|e| format!("error converting supplied value for src_addr: {}", e)); + self + } + pub fn src_uuid(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.src_uuid = value + .try_into() + .map_err(|e| format!("error converting supplied value for src_uuid: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateInitiateRequest + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateRequest, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + src_addr: value.src_addr?, + src_uuid: value.src_uuid?, + }) + } + } + + impl ::std::convert::From + for InstanceMigrateInitiateRequest + { + fn from(value: super::InstanceMigrateInitiateRequest) -> Self { + Self { + migration_id: Ok(value.migration_id), + src_addr: Ok(value.src_addr), + src_uuid: Ok(value.src_uuid), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateInitiateResponse { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateInitiateResponse { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + } + } + } + + impl InstanceMigrateInitiateResponse { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateInitiateResponse + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateResponse, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + }) + } + } + + impl ::std::convert::From + for InstanceMigrateInitiateResponse + { + fn from(value: super::InstanceMigrateInitiateResponse) -> Self { + Self { + migration_id: Ok(value.migration_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateStatusRequest { + migration_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + } + + impl ::std::default::Default for InstanceMigrateStatusRequest { + fn default() -> Self { + Self { + migration_id: Err("no value supplied for migration_id".to_string()), + } + } + } + + impl InstanceMigrateStatusRequest { + pub fn migration_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.migration_id = value.try_into().map_err(|e| { + format!("error converting supplied value for migration_id: {}", e) + }); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceMigrateStatusRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusRequest, + ) -> ::std::result::Result { + Ok(Self { + migration_id: value.migration_id?, + }) + } + } + + impl ::std::convert::From for InstanceMigrateStatusRequest { + fn from(value: super::InstanceMigrateStatusRequest) -> Self { + Self { + migration_id: Ok(value.migration_id), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceMigrateStatusResponse { + state: ::std::result::Result, + } + + impl ::std::default::Default for InstanceMigrateStatusResponse { + fn default() -> Self { + Self { + state: Err("no value supplied for state".to_string()), + } + } + } + + impl InstanceMigrateStatusResponse { + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom + for super::InstanceMigrateStatusResponse + { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusResponse, + ) -> ::std::result::Result { + Ok(Self { + state: value.state?, + }) + } + } + + impl ::std::convert::From for InstanceMigrateStatusResponse { + fn from(value: super::InstanceMigrateStatusResponse) -> Self { + Self { + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceProperties { + bootrom_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + description: ::std::result::Result<::std::string::String, ::std::string::String>, + id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + image_id: ::std::result::Result<::uuid::Uuid, ::std::string::String>, + memory: ::std::result::Result, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + vcpus: ::std::result::Result, + } + + impl ::std::default::Default for InstanceProperties { + fn default() -> Self { + Self { + bootrom_id: Err("no value supplied for bootrom_id".to_string()), + description: Err("no value supplied for description".to_string()), + id: Err("no value supplied for id".to_string()), + image_id: Err("no value supplied for image_id".to_string()), + memory: Err("no value supplied for memory".to_string()), + name: Err("no value supplied for name".to_string()), + vcpus: Err("no value supplied for vcpus".to_string()), + } + } + } + + impl InstanceProperties { + pub fn bootrom_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.bootrom_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for bootrom_id: {}", e)); + self + } + pub fn description(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.description = value + .try_into() + .map_err(|e| format!("error converting supplied value for description: {}", e)); + self + } + pub fn id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.id = value + .try_into() + .map_err(|e| format!("error converting supplied value for id: {}", e)); + self + } + pub fn image_id(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::uuid::Uuid>, + T::Error: ::std::fmt::Display, + { + self.image_id = value + .try_into() + .map_err(|e| format!("error converting supplied value for image_id: {}", e)); + self + } + pub fn memory(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.memory = value + .try_into() + .map_err(|e| format!("error converting supplied value for memory: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn vcpus(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.vcpus = value + .try_into() + .map_err(|e| format!("error converting supplied value for vcpus: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceProperties { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceProperties, + ) -> ::std::result::Result { + Ok(Self { + bootrom_id: value.bootrom_id?, + description: value.description?, + id: value.id?, + image_id: value.image_id?, + memory: value.memory?, + name: value.name?, + vcpus: value.vcpus?, + }) + } + } + + impl ::std::convert::From for InstanceProperties { + fn from(value: super::InstanceProperties) -> Self { + Self { + bootrom_id: Ok(value.bootrom_id), + description: Ok(value.description), + id: Ok(value.id), + image_id: Ok(value.image_id), + memory: Ok(value.memory), + name: Ok(value.name), + vcpus: Ok(value.vcpus), + } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceStateMonitorRequest { + gen: ::std::result::Result, + } + + impl ::std::default::Default for InstanceStateMonitorRequest { + fn default() -> Self { + Self { + gen: Err("no value supplied for gen".to_string()), + } + } + } + + impl InstanceStateMonitorRequest { + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceStateMonitorRequest { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorRequest, + ) -> ::std::result::Result { + Ok(Self { gen: value.gen? }) + } + } + + impl ::std::convert::From for InstanceStateMonitorRequest { + fn from(value: super::InstanceStateMonitorRequest) -> Self { + Self { gen: Ok(value.gen) } + } + } + + #[derive(Clone, Debug)] + pub struct InstanceStateMonitorResponse { + gen: ::std::result::Result, + state: ::std::result::Result, + } + + impl ::std::default::Default for InstanceStateMonitorResponse { + fn default() -> Self { + Self { + gen: Err("no value supplied for gen".to_string()), + state: Err("no value supplied for state".to_string()), + } + } + } + + impl InstanceStateMonitorResponse { + pub fn gen(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.gen = value + .try_into() + .map_err(|e| format!("error converting supplied value for gen: {}", e)); + self + } + pub fn state(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.state = value + .try_into() + .map_err(|e| format!("error converting supplied value for state: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::InstanceStateMonitorResponse { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorResponse, + ) -> ::std::result::Result { + Ok(Self { + gen: value.gen?, + state: value.state?, + }) + } + } + + impl ::std::convert::From for InstanceStateMonitorResponse { + fn from(value: super::InstanceStateMonitorResponse) -> Self { + Self { + gen: Ok(value.gen), + state: Ok(value.state), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterface { + attachment: ::std::result::Result< + super::NetworkInterfaceAttachmentState, + ::std::string::String, + >, + name: ::std::result::Result<::std::string::String, ::std::string::String>, + } + + impl ::std::default::Default for NetworkInterface { + fn default() -> Self { + Self { + attachment: Err("no value supplied for attachment".to_string()), + name: Err("no value supplied for name".to_string()), + } + } + } + + impl NetworkInterface { + pub fn attachment(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.attachment = value + .try_into() + .map_err(|e| format!("error converting supplied value for attachment: {}", e)); + self + } + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterface { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterface, + ) -> ::std::result::Result { + Ok(Self { + attachment: value.attachment?, + name: value.name?, + }) + } + } + + impl ::std::convert::From for NetworkInterface { + fn from(value: super::NetworkInterface) -> Self { + Self { + attachment: Ok(value.attachment), + name: Ok(value.name), + } + } + } + + #[derive(Clone, Debug)] + pub struct NetworkInterfaceRequest { + name: ::std::result::Result<::std::string::String, ::std::string::String>, + slot: ::std::result::Result, + } + + impl ::std::default::Default for NetworkInterfaceRequest { + fn default() -> Self { + Self { + name: Err("no value supplied for name".to_string()), + slot: Err("no value supplied for slot".to_string()), + } + } + } + + impl NetworkInterfaceRequest { + pub fn name(mut self, value: T) -> Self + where + T: ::std::convert::TryInto<::std::string::String>, + T::Error: ::std::fmt::Display, + { + self.name = value + .try_into() + .map_err(|e| format!("error converting supplied value for name: {}", e)); + self + } + pub fn slot(mut self, value: T) -> Self + where + T: ::std::convert::TryInto, + T::Error: ::std::fmt::Display, + { + self.slot = value + .try_into() + .map_err(|e| format!("error converting supplied value for slot: {}", e)); + self + } + } + + impl ::std::convert::TryFrom for super::NetworkInterfaceRequest { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceRequest, + ) -> ::std::result::Result { + Ok(Self { + name: value.name?, + slot: value.slot?, + }) + } + } + + impl ::std::convert::From for NetworkInterfaceRequest { + fn from(value: super::NetworkInterfaceRequest) -> Self { + Self { + name: Ok(value.name), + slot: Ok(value.slot), + } + } + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +impl Client { + ///Sends a `GET` request to `/instance` + /// + ///```ignore + /// let response = client.instance_get() + /// .send() + /// .await; + /// ``` + pub fn instance_get(&self) -> builder::InstanceGet<'_> { + builder::InstanceGet::new(self) + } + + ///Sends a `PUT` request to `/instance` + /// + ///```ignore + /// let response = client.instance_ensure() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_ensure(&self) -> builder::InstanceEnsure<'_> { + builder::InstanceEnsure::new(self) + } + + ///Issue a snapshot request to a crucible backend + /// + ///Sends a `POST` request to `/instance/disk/{id}/snapshot/{snapshot_id}` + /// + ///```ignore + /// let response = client.instance_issue_crucible_snapshot_request() + /// .id(id) + /// .snapshot_id(snapshot_id) + /// .send() + /// .await; + /// ``` + pub fn instance_issue_crucible_snapshot_request( + &self, + ) -> builder::InstanceIssueCrucibleSnapshotRequest<'_> { + builder::InstanceIssueCrucibleSnapshotRequest::new(self) + } + + ///Sends a `GET` request to `/instance/migrate/status` + /// + ///```ignore + /// let response = client.instance_migrate_status() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_migrate_status(&self) -> builder::InstanceMigrateStatus<'_> { + builder::InstanceMigrateStatus::new(self) + } + + ///Sends a `GET` request to `/instance/serial` + /// + ///```ignore + /// let response = client.instance_serial() + /// .send() + /// .await; + /// ``` + pub fn instance_serial(&self) -> builder::InstanceSerial<'_> { + builder::InstanceSerial::new(self) + } + + ///Sends a `PUT` request to `/instance/state` + /// + ///```ignore + /// let response = client.instance_state_put() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_state_put(&self) -> builder::InstanceStatePut<'_> { + builder::InstanceStatePut::new(self) + } + + ///Sends a `GET` request to `/instance/state-monitor` + /// + ///```ignore + /// let response = client.instance_state_monitor() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_state_monitor(&self) -> builder::InstanceStateMonitor<'_> { + builder::InstanceStateMonitor::new(self) + } +} + +/// Types for composing operation parameters. +#[allow(clippy::all)] +pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ + encode_path, ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt, + ResponseValue, + }; + ///Builder for [`Client::instance_get`] + /// + ///[`Client::instance_get`]: super::Client::instance_get + #[derive(Debug, Clone)] + pub struct InstanceGet<'a> { + client: &'a super::Client, + } + + impl<'a> InstanceGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/instance` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/instance", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_get", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_ensure`] + /// + ///[`Client::instance_ensure`]: super::Client::instance_ensure + #[derive(Debug, Clone)] + pub struct InstanceEnsure<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceEnsure<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceEnsureRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceEnsureRequest, + ) -> types::builder::InstanceEnsureRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `PUT` request to `/instance` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_ensure", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_issue_crucible_snapshot_request`] + /// + ///[`Client::instance_issue_crucible_snapshot_request`]: super::Client::instance_issue_crucible_snapshot_request + #[derive(Debug, Clone)] + pub struct InstanceIssueCrucibleSnapshotRequest<'a> { + client: &'a super::Client, + id: Result<::uuid::Uuid, String>, + snapshot_id: Result<::uuid::Uuid, String>, + } + + impl<'a> InstanceIssueCrucibleSnapshotRequest<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + id: Err("id was not initialized".to_string()), + snapshot_id: Err("snapshot_id was not initialized".to_string()), + } + } + + pub fn id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for id failed".to_string()); + self + } + + pub fn snapshot_id(mut self, value: V) -> Self + where + V: std::convert::TryInto<::uuid::Uuid>, + { + self.snapshot_id = value + .try_into() + .map_err(|_| "conversion to `:: uuid :: Uuid` for snapshot_id failed".to_string()); + self + } + + ///Sends a `POST` request to + /// `/instance/disk/{id}/snapshot/{snapshot_id}` + pub async fn send(self) -> Result, Error> { + let Self { + client, + id, + snapshot_id, + } = self; + let id = id.map_err(Error::InvalidRequest)?; + let snapshot_id = snapshot_id.map_err(Error::InvalidRequest)?; + let url = format!( + "{}/instance/disk/{}/snapshot/{}", + client.baseurl, + encode_path(&id.to_string()), + encode_path(&snapshot_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_issue_crucible_snapshot_request", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_migrate_status`] + /// + ///[`Client::instance_migrate_status`]: super::Client::instance_migrate_status + #[derive(Debug, Clone)] + pub struct InstanceMigrateStatus<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceMigrateStatus<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceMigrateStatusRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceMigrateStatusRequest, + ) -> types::builder::InstanceMigrateStatusRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/instance/migrate/status` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::InstanceMigrateStatusRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/migrate/status", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_status", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_serial`] + /// + ///[`Client::instance_serial`]: super::Client::instance_serial + #[derive(Debug, Clone)] + pub struct InstanceSerial<'a> { + client: &'a super::Client, + } + + impl<'a> InstanceSerial<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client: client } + } + + ///Sends a `GET` request to `/instance/serial` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/instance/serial", client.baseurl,); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + } + + ///Builder for [`Client::instance_state_put`] + /// + ///[`Client::instance_state_put`]: super::Client::instance_state_put + #[derive(Debug, Clone)] + pub struct InstanceStatePut<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceStatePut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Err("body was not initialized".to_string()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.body = value + .try_into() + .map_err(|_| "conversion to `InstanceStateRequested` for body failed".to_string()); + self + } + + ///Sends a `PUT` request to `/instance/state` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let body = body.map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/state", client.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_put", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::instance_state_monitor`] + /// + ///[`Client::instance_state_monitor`]: super::Client::instance_state_monitor + #[derive(Debug, Clone)] + pub struct InstanceStateMonitor<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> InstanceStateMonitor<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(::std::default::Default::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: + std::fmt::Display, + { + self.body = value.try_into().map(From::from).map_err(|s| { + format!( + "conversion to `InstanceStateMonitorRequest` for body failed: {}", + s + ) + }); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceStateMonitorRequest, + ) -> types::builder::InstanceStateMonitorRequest, + { + self.body = self.body.map(f); + self + } + + ///Sends a `GET` request to `/instance/state-monitor` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { client, body } = self; + let body = body + .and_then(|v| { + types::InstanceStateMonitorRequest::try_from(v).map_err(|e| e.to_string()) + }) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/instance/state-monitor", client.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", super::Client::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_monitor", + }; + let result = client.exec(request, &info).await; + client.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} + +/// Items consumers will typically use such as the Client and +/// extension traits. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/gloo_backend/propolis_server_positional.rs b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_positional.rs new file mode 100644 index 00000000..40481716 --- /dev/null +++ b/progenitor-impl/tests/output/src/gloo_backend/propolis_server_positional.rs @@ -0,0 +1,1730 @@ +#[allow(unused_imports)] +use progenitor_client::{encode_path, ClientHooks, OperationInfo, RequestBuilderExt}; +#[allow(unused_imports)] +pub use progenitor_client::{ByteStream, ClientInfo, Error, ResponseValue}; +/// Types used as operation parameters and responses. +#[allow(clippy::all)] +pub mod types { + /// Error types. + pub mod error { + /// Error from a `TryFrom` or `FromStr` implementation. + pub struct ConversionError(::std::borrow::Cow<'static, str>); + impl ::std::error::Error for ConversionError {} + impl ::std::fmt::Display for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Display::fmt(&self.0, f) + } + } + + impl ::std::fmt::Debug for ConversionError { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { + ::std::fmt::Debug::fmt(&self.0, f) + } + } + + impl From<&'static str> for ConversionError { + fn from(value: &'static str) -> Self { + Self(value.into()) + } + } + + impl From for ConversionError { + fn from(value: String) -> Self { + Self(value.into()) + } + } + } + + ///`CrucibleOpts` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "id", + /// "lossy", + /// "read_only", + /// "target" + /// ], + /// "properties": { + /// "cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "control": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "flush_timeout": { + /// "type": [ + /// "integer", + /// "null" + /// ], + /// "format": "uint32", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "key": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "key_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "lossy": { + /// "type": "boolean" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "root_cert_pem": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "target": { + /// "type": "array", + /// "items": { + /// "type": "string" + /// } + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct CrucibleOpts { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cert_pem: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub control: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub flush_timeout: ::std::option::Option, + pub id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub key_pem: ::std::option::Option<::std::string::String>, + pub lossy: bool, + pub read_only: bool, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub root_cert_pem: ::std::option::Option<::std::string::String>, + pub target: ::std::vec::Vec<::std::string::String>, + } + + impl ::std::convert::From<&CrucibleOpts> for CrucibleOpts { + fn from(value: &CrucibleOpts) -> Self { + value.clone() + } + } + + ///`DiskAttachment` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disk_id", + /// "generation_id", + /// "state" + /// ], + /// "properties": { + /// "disk_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "generation_id": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/DiskAttachmentState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskAttachment { + pub disk_id: ::uuid::Uuid, + pub generation_id: u64, + pub state: DiskAttachmentState, + } + + impl ::std::convert::From<&DiskAttachment> for DiskAttachment { + fn from(value: &DiskAttachment) -> Self { + value.clone() + } + } + + ///`DiskAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Destroyed", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "type": "string", + /// "format": "uuid" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub enum DiskAttachmentState { + Detached, + Destroyed, + Faulted, + Attached(::uuid::Uuid), + } + + impl ::std::convert::From<&Self> for DiskAttachmentState { + fn from(value: &DiskAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From<::uuid::Uuid> for DiskAttachmentState { + fn from(value: ::uuid::Uuid) -> Self { + Self::Attached(value) + } + } + + ///`DiskRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "device", + /// "gen", + /// "name", + /// "read_only", + /// "slot", + /// "volume_construction_request" + /// ], + /// "properties": { + /// "device": { + /// "type": "string" + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "type": "string" + /// }, + /// "read_only": { + /// "type": "boolean" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// }, + /// "volume_construction_request": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct DiskRequest { + pub device: ::std::string::String, + pub gen: u64, + pub name: ::std::string::String, + pub read_only: bool, + pub slot: Slot, + pub volume_construction_request: VolumeConstructionRequest, + } + + impl ::std::convert::From<&DiskRequest> for DiskRequest { + fn from(value: &DiskRequest) -> Self { + value.clone() + } + } + + ///Error information from a response. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Error information from a response.", + /// "type": "object", + /// "required": [ + /// "message", + /// "request_id" + /// ], + /// "properties": { + /// "error_code": { + /// "type": "string" + /// }, + /// "message": { + /// "type": "string" + /// }, + /// "request_id": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Error { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub error_code: ::std::option::Option<::std::string::String>, + pub message: ::std::string::String, + pub request_id: ::std::string::String, + } + + impl ::std::convert::From<&Error> for Error { + fn from(value: &Error) -> Self { + value.clone() + } + } + + ///`Instance` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "disks", + /// "nics", + /// "properties", + /// "state" + /// ], + /// "properties": { + /// "disks": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskAttachment" + /// } + /// }, + /// "nics": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterface" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct Instance { + pub disks: ::std::vec::Vec, + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + pub state: InstanceState, + } + + impl ::std::convert::From<&Instance> for Instance { + fn from(value: &Instance) -> Self { + value.clone() + } + } + + ///`InstanceEnsureRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "properties" + /// ], + /// "properties": { + /// "cloud_init_bytes": { + /// "type": [ + /// "string", + /// "null" + /// ] + /// }, + /// "disks": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/DiskRequest" + /// } + /// }, + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "nics": { + /// "default": [], + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/NetworkInterfaceRequest" + /// } + /// }, + /// "properties": { + /// "$ref": "#/components/schemas/InstanceProperties" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceEnsureRequest { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub cloud_init_bytes: ::std::option::Option<::std::string::String>, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub disks: ::std::vec::Vec, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")] + pub nics: ::std::vec::Vec, + pub properties: InstanceProperties, + } + + impl ::std::convert::From<&InstanceEnsureRequest> for InstanceEnsureRequest { + fn from(value: &InstanceEnsureRequest) -> Self { + value.clone() + } + } + + ///`InstanceEnsureResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "properties": { + /// "migrate": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/InstanceMigrateInitiateResponse" + /// } + /// ] + /// } + /// ] + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceEnsureResponse { + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + pub migrate: ::std::option::Option, + } + + impl ::std::convert::From<&InstanceEnsureResponse> for InstanceEnsureResponse { + fn from(value: &InstanceEnsureResponse) -> Self { + value.clone() + } + } + + impl ::std::default::Default for InstanceEnsureResponse { + fn default() -> Self { + Self { + migrate: Default::default(), + } + } + } + + ///`InstanceGetResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "instance" + /// ], + /// "properties": { + /// "instance": { + /// "$ref": "#/components/schemas/Instance" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceGetResponse { + pub instance: Instance, + } + + impl ::std::convert::From<&InstanceGetResponse> for InstanceGetResponse { + fn from(value: &InstanceGetResponse) -> Self { + value.clone() + } + } + + ///`InstanceMigrateInitiateRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id", + /// "src_addr", + /// "src_uuid" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "src_addr": { + /// "type": "string" + /// }, + /// "src_uuid": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateInitiateRequest { + pub migration_id: ::uuid::Uuid, + pub src_addr: ::std::string::String, + pub src_uuid: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateRequest> for InstanceMigrateInitiateRequest { + fn from(value: &InstanceMigrateInitiateRequest) -> Self { + value.clone() + } + } + + ///`InstanceMigrateInitiateResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateInitiateResponse { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateInitiateResponse> for InstanceMigrateInitiateResponse { + fn from(value: &InstanceMigrateInitiateResponse) -> Self { + value.clone() + } + } + + ///`InstanceMigrateStatusRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "migration_id" + /// ], + /// "properties": { + /// "migration_id": { + /// "type": "string", + /// "format": "uuid" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateStatusRequest { + pub migration_id: ::uuid::Uuid, + } + + impl ::std::convert::From<&InstanceMigrateStatusRequest> for InstanceMigrateStatusRequest { + fn from(value: &InstanceMigrateStatusRequest) -> Self { + value.clone() + } + } + + ///`InstanceMigrateStatusResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "state" + /// ], + /// "properties": { + /// "state": { + /// "$ref": "#/components/schemas/MigrationState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceMigrateStatusResponse { + pub state: MigrationState, + } + + impl ::std::convert::From<&InstanceMigrateStatusResponse> for InstanceMigrateStatusResponse { + fn from(value: &InstanceMigrateStatusResponse) -> Self { + value.clone() + } + } + + ///`InstanceProperties` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "bootrom_id", + /// "description", + /// "id", + /// "image_id", + /// "memory", + /// "name", + /// "vcpus" + /// ], + /// "properties": { + /// "bootrom_id": { + /// "description": "ID of the bootrom used to initialize this + /// Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "description": { + /// "description": "Free-form text description of an Instance.", + /// "type": "string" + /// }, + /// "id": { + /// "description": "Unique identifier for this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "image_id": { + /// "description": "ID of the image used to initialize this Instance.", + /// "type": "string", + /// "format": "uuid" + /// }, + /// "memory": { + /// "description": "Size of memory allocated to the Instance, in MiB.", + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "name": { + /// "description": "Human-readable name of the Instance.", + /// "type": "string" + /// }, + /// "vcpus": { + /// "description": "Number of vCPUs to be allocated to the Instance.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceProperties { + ///ID of the bootrom used to initialize this Instance. + pub bootrom_id: ::uuid::Uuid, + ///Free-form text description of an Instance. + pub description: ::std::string::String, + ///Unique identifier for this Instance. + pub id: ::uuid::Uuid, + ///ID of the image used to initialize this Instance. + pub image_id: ::uuid::Uuid, + ///Size of memory allocated to the Instance, in MiB. + pub memory: u64, + ///Human-readable name of the Instance. + pub name: ::std::string::String, + ///Number of vCPUs to be allocated to the Instance. + pub vcpus: u8, + } + + impl ::std::convert::From<&InstanceProperties> for InstanceProperties { + fn from(value: &InstanceProperties) -> Self { + value.clone() + } + } + + ///Current state of an Instance. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "Current state of an Instance.", + /// "type": "string", + /// "enum": [ + /// "Creating", + /// "Starting", + /// "Running", + /// "Stopping", + /// "Stopped", + /// "Rebooting", + /// "Migrating", + /// "Repairing", + /// "Failed", + /// "Destroyed" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceState { + Creating, + Starting, + Running, + Stopping, + Stopped, + Rebooting, + Migrating, + Repairing, + Failed, + Destroyed, + } + + impl ::std::convert::From<&Self> for InstanceState { + fn from(value: &InstanceState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Creating => f.write_str("Creating"), + Self::Starting => f.write_str("Starting"), + Self::Running => f.write_str("Running"), + Self::Stopping => f.write_str("Stopping"), + Self::Stopped => f.write_str("Stopped"), + Self::Rebooting => f.write_str("Rebooting"), + Self::Migrating => f.write_str("Migrating"), + Self::Repairing => f.write_str("Repairing"), + Self::Failed => f.write_str("Failed"), + Self::Destroyed => f.write_str("Destroyed"), + } + } + } + + impl ::std::str::FromStr for InstanceState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Creating" => Ok(Self::Creating), + "Starting" => Ok(Self::Starting), + "Running" => Ok(Self::Running), + "Stopping" => Ok(Self::Stopping), + "Stopped" => Ok(Self::Stopped), + "Rebooting" => Ok(Self::Rebooting), + "Migrating" => Ok(Self::Migrating), + "Repairing" => Ok(Self::Repairing), + "Failed" => Ok(Self::Failed), + "Destroyed" => Ok(Self::Destroyed), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`InstanceStateMonitorRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceStateMonitorRequest { + pub gen: u64, + } + + impl ::std::convert::From<&InstanceStateMonitorRequest> for InstanceStateMonitorRequest { + fn from(value: &InstanceStateMonitorRequest) -> Self { + value.clone() + } + } + + ///`InstanceStateMonitorResponse` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "gen", + /// "state" + /// ], + /// "properties": { + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "state": { + /// "$ref": "#/components/schemas/InstanceState" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct InstanceStateMonitorResponse { + pub gen: u64, + pub state: InstanceState, + } + + impl ::std::convert::From<&InstanceStateMonitorResponse> for InstanceStateMonitorResponse { + fn from(value: &InstanceStateMonitorResponse) -> Self { + value.clone() + } + } + + ///`InstanceStateRequested` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Run", + /// "Stop", + /// "Reboot", + /// "MigrateStart" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum InstanceStateRequested { + Run, + Stop, + Reboot, + MigrateStart, + } + + impl ::std::convert::From<&Self> for InstanceStateRequested { + fn from(value: &InstanceStateRequested) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for InstanceStateRequested { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Run => f.write_str("Run"), + Self::Stop => f.write_str("Stop"), + Self::Reboot => f.write_str("Reboot"), + Self::MigrateStart => f.write_str("MigrateStart"), + } + } + } + + impl ::std::str::FromStr for InstanceStateRequested { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Run" => Ok(Self::Run), + "Stop" => Ok(Self::Stop), + "Reboot" => Ok(Self::Reboot), + "MigrateStart" => Ok(Self::MigrateStart), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for InstanceStateRequested { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`MigrationState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "string", + /// "enum": [ + /// "Sync", + /// "RamPush", + /// "Pause", + /// "RamPushDirty", + /// "Device", + /// "Arch", + /// "Resume", + /// "RamPull", + /// "Finish", + /// "Error" + /// ] + ///} + /// ``` + ///
+ #[derive( + :: serde :: Deserialize, + :: serde :: Serialize, + Clone, + Copy, + Debug, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + )] + pub enum MigrationState { + Sync, + RamPush, + Pause, + RamPushDirty, + Device, + Arch, + Resume, + RamPull, + Finish, + Error, + } + + impl ::std::convert::From<&Self> for MigrationState { + fn from(value: &MigrationState) -> Self { + value.clone() + } + } + + impl ::std::fmt::Display for MigrationState { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + match *self { + Self::Sync => f.write_str("Sync"), + Self::RamPush => f.write_str("RamPush"), + Self::Pause => f.write_str("Pause"), + Self::RamPushDirty => f.write_str("RamPushDirty"), + Self::Device => f.write_str("Device"), + Self::Arch => f.write_str("Arch"), + Self::Resume => f.write_str("Resume"), + Self::RamPull => f.write_str("RamPull"), + Self::Finish => f.write_str("Finish"), + Self::Error => f.write_str("Error"), + } + } + } + + impl ::std::str::FromStr for MigrationState { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> ::std::result::Result { + match value { + "Sync" => Ok(Self::Sync), + "RamPush" => Ok(Self::RamPush), + "Pause" => Ok(Self::Pause), + "RamPushDirty" => Ok(Self::RamPushDirty), + "Device" => Ok(Self::Device), + "Arch" => Ok(Self::Arch), + "Resume" => Ok(Self::Resume), + "RamPull" => Ok(Self::RamPull), + "Finish" => Ok(Self::Finish), + "Error" => Ok(Self::Error), + _ => Err("invalid value".into()), + } + } + } + + impl ::std::convert::TryFrom<&str> for MigrationState { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: &::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<::std::string::String> for MigrationState { + type Error = self::error::ConversionError; + fn try_from( + value: ::std::string::String, + ) -> ::std::result::Result { + value.parse() + } + } + + ///`NetworkInterface` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "attachment", + /// "name" + /// ], + /// "properties": { + /// "attachment": { + /// "$ref": "#/components/schemas/NetworkInterfaceAttachmentState" + /// }, + /// "name": { + /// "type": "string" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterface { + pub attachment: NetworkInterfaceAttachmentState, + pub name: ::std::string::String, + } + + impl ::std::convert::From<&NetworkInterface> for NetworkInterface { + fn from(value: &NetworkInterface) -> Self { + value.clone() + } + } + + ///`NetworkInterfaceAttachmentState` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "string", + /// "enum": [ + /// "Detached", + /// "Faulted" + /// ] + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "Attached" + /// ], + /// "properties": { + /// "Attached": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// }, + /// "additionalProperties": false + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub enum NetworkInterfaceAttachmentState { + Detached, + Faulted, + Attached(Slot), + } + + impl ::std::convert::From<&Self> for NetworkInterfaceAttachmentState { + fn from(value: &NetworkInterfaceAttachmentState) -> Self { + value.clone() + } + } + + impl ::std::convert::From for NetworkInterfaceAttachmentState { + fn from(value: Slot) -> Self { + Self::Attached(value) + } + } + + ///`NetworkInterfaceRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "type": "object", + /// "required": [ + /// "name", + /// "slot" + /// ], + /// "properties": { + /// "name": { + /// "type": "string" + /// }, + /// "slot": { + /// "$ref": "#/components/schemas/Slot" + /// } + /// } + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + pub struct NetworkInterfaceRequest { + pub name: ::std::string::String, + pub slot: Slot, + } + + impl ::std::convert::From<&NetworkInterfaceRequest> for NetworkInterfaceRequest { + fn from(value: &NetworkInterfaceRequest) -> Self { + value.clone() + } + } + + ///A stable index which is translated by Propolis into a PCI BDF, visible + /// to the guest. + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "description": "A stable index which is translated by Propolis into a + /// PCI BDF, visible to the guest.", + /// "type": "integer", + /// "format": "uint8", + /// "minimum": 0.0 + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(transparent)] + pub struct Slot(pub u8); + impl ::std::ops::Deref for Slot { + type Target = u8; + fn deref(&self) -> &u8 { + &self.0 + } + } + + impl ::std::convert::From for u8 { + fn from(value: Slot) -> Self { + value.0 + } + } + + impl ::std::convert::From<&Slot> for Slot { + fn from(value: &Slot) -> Self { + value.clone() + } + } + + impl ::std::convert::From for Slot { + fn from(value: u8) -> Self { + Self(value) + } + } + + impl ::std::str::FromStr for Slot { + type Err = ::Err; + fn from_str(value: &str) -> ::std::result::Result { + Ok(Self(value.parse()?)) + } + } + + impl ::std::convert::TryFrom<&str> for Slot { + type Error = ::Err; + fn try_from(value: &str) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom<&String> for Slot { + type Error = ::Err; + fn try_from(value: &String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::convert::TryFrom for Slot { + type Error = ::Err; + fn try_from(value: String) -> ::std::result::Result { + value.parse() + } + } + + impl ::std::fmt::Display for Slot { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + self.0.fmt(f) + } + } + + ///`VolumeConstructionRequest` + /// + ///
JSON schema + /// + /// ```json + ///{ + /// "oneOf": [ + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "sub_volumes", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "read_only_parent": { + /// "oneOf": [ + /// { + /// "type": "null" + /// }, + /// { + /// "allOf": [ + /// { + /// "$ref": + /// "#/components/schemas/VolumeConstructionRequest" + /// } + /// ] + /// } + /// ] + /// }, + /// "sub_volumes": { + /// "type": "array", + /// "items": { + /// "$ref": "#/components/schemas/VolumeConstructionRequest" + /// } + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "volume" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "type", + /// "url" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "url" + /// ] + /// }, + /// "url": { + /// "type": "string" + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "gen", + /// "opts", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "gen": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "opts": { + /// "$ref": "#/components/schemas/CrucibleOpts" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "region" + /// ] + /// } + /// } + /// }, + /// { + /// "type": "object", + /// "required": [ + /// "block_size", + /// "id", + /// "path", + /// "type" + /// ], + /// "properties": { + /// "block_size": { + /// "type": "integer", + /// "format": "uint64", + /// "minimum": 0.0 + /// }, + /// "id": { + /// "type": "string", + /// "format": "uuid" + /// }, + /// "path": { + /// "type": "string" + /// }, + /// "type": { + /// "type": "string", + /// "enum": [ + /// "file" + /// ] + /// } + /// } + /// } + /// ] + ///} + /// ``` + ///
+ #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] + #[serde(tag = "type")] + pub enum VolumeConstructionRequest { + #[serde(rename = "volume")] + Volume { + block_size: u64, + id: ::uuid::Uuid, + #[serde(default, skip_serializing_if = "::std::option::Option::is_none")] + read_only_parent: ::std::option::Option<::std::boxed::Box>, + sub_volumes: ::std::vec::Vec, + }, + #[serde(rename = "url")] + Url { + block_size: u64, + id: ::uuid::Uuid, + url: ::std::string::String, + }, + #[serde(rename = "region")] + Region { + block_size: u64, + gen: u64, + opts: CrucibleOpts, + }, + #[serde(rename = "file")] + File { + block_size: u64, + id: ::uuid::Uuid, + path: ::std::string::String, + }, + } + + impl ::std::convert::From<&Self> for VolumeConstructionRequest { + fn from(value: &VolumeConstructionRequest) -> Self { + value.clone() + } + } +} + +#[derive(Clone, Debug)] +///Client for Oxide Propolis Server API +/// +///API for interacting with the Propolis hypervisor frontend. +/// +///Version: 0.0.1 +pub struct Client { + pub(crate) baseurl: String, +} + +impl Client { + /// Create a new client. + /// + /// `baseurl` is the base URL to which requests are made. + pub fn new(baseurl: &str) -> Self { + Self { + baseurl: baseurl.to_string(), + } + } +} + +impl ClientInfo<()> for Client { + fn api_version() -> &'static str { + "0.0.1" + } + + fn baseurl(&self) -> &str { + self.baseurl.as_str() + } + + fn inner(&self) -> &() { + &() + } +} + +impl ClientHooks<()> for &Client {} +#[allow(clippy::all)] +impl Client { + ///Sends a `GET` request to `/instance` + pub async fn instance_get<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/instance", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_get", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `PUT` request to `/instance` + pub async fn instance_ensure<'a>( + &'a self, + body: &'a types::InstanceEnsureRequest, + ) -> Result, Error> { + let url = format!("{}/instance", self.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_ensure", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 201u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Issue a snapshot request to a crucible backend + /// + ///Sends a `POST` request to `/instance/disk/{id}/snapshot/{snapshot_id}` + pub async fn instance_issue_crucible_snapshot_request<'a>( + &'a self, + id: &'a ::uuid::Uuid, + snapshot_id: &'a ::uuid::Uuid, + ) -> Result, Error> { + let url = format!( + "{}/instance/disk/{}/snapshot/{}", + self.baseurl, + encode_path(&id.to_string()), + encode_path(&snapshot_id.to_string()), + ); + let request = ::gloo_net::http::Request::post(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .build()?; + let info = OperationInfo { + operation_id: "instance_issue_crucible_snapshot_request", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/instance/migrate/status` + pub async fn instance_migrate_status<'a>( + &'a self, + body: &'a types::InstanceMigrateStatusRequest, + ) -> Result, Error> { + let url = format!("{}/instance/migrate/status", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_migrate_status", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/instance/serial` + pub async fn instance_serial<'a>( + &'a self, + ) -> Result, Error> { + let url = format!("{}/instance/serial", self.baseurl,); + let ws_url = url + .replace("https://", "wss://") + .replace("http://", "ws://"); + let ws = ::web_sys::WebSocket::new(&ws_url) + .map_err(|e| Error::Custom(format!("Failed to create WebSocket: {:?}", e)))?; + ResponseValue::websocket(ws) + } + + ///Sends a `PUT` request to `/instance/state` + pub async fn instance_state_put<'a>( + &'a self, + body: types::InstanceStateRequested, + ) -> Result, Error> { + let url = format!("{}/instance/state", self.baseurl,); + let request = ::gloo_net::http::Request::put(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_put", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 204u16 => Ok(ResponseValue::empty(response)), + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + ///Sends a `GET` request to `/instance/state-monitor` + pub async fn instance_state_monitor<'a>( + &'a self, + body: &'a types::InstanceStateMonitorRequest, + ) -> Result, Error> { + let url = format!("{}/instance/state-monitor", self.baseurl,); + let request = ::gloo_net::http::Request::get(&url) + .header("accept", "application/json") + .header("api-version", Self::api_version()) + .json(&body)?; + let info = OperationInfo { + operation_id: "instance_state_monitor", + }; + let result = self.exec(request, &info).await; + self.post(&result, &info).await?; + let response = result?; + match response.status() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } +} + +/// Items consumers will typically use such as the Client. +pub mod prelude { + #[allow(unused_imports)] + pub use super::Client; +} diff --git a/progenitor-impl/tests/output/src/lib.rs b/progenitor-impl/tests/output/src/lib.rs index 1bb9e956..8ade4388 100644 --- a/progenitor-impl/tests/output/src/lib.rs +++ b/progenitor-impl/tests/output/src/lib.rs @@ -1,34 +1,71 @@ -pub mod buildomat_builder; -pub mod buildomat_builder_tagged; -pub mod buildomat_cli; -//pub mod buildomat_httpmock; -pub mod buildomat_positional; -pub mod keeper_builder; -pub mod keeper_builder_tagged; -pub mod keeper_cli; -pub mod keeper_httpmock; -pub mod keeper_positional; -pub mod nexus_builder; -pub mod nexus_builder_tagged; -pub mod nexus_cli; -pub mod nexus_httpmock; -pub mod nexus_positional; -pub mod param_collision_builder; -pub mod param_collision_builder_tagged; -pub mod param_collision_cli; -pub mod param_collision_httpmock; -pub mod param_collision_positional; -pub mod param_overrides_builder; -pub mod param_overrides_builder_tagged; -pub mod param_overrides_cli; -pub mod param_overrides_httpmock; -pub mod param_overrides_positional; -pub mod propolis_server_builder; -pub mod propolis_server_builder_tagged; -pub mod propolis_server_cli; -//pub mod propolis_server_httpmock; -pub mod propolis_server_positional; -pub mod test_default_params_builder; -pub mod test_default_params_positional; -pub mod test_freeform_response; -pub mod test_renamed_parameters; +#[cfg(not(target_arch = "wasm32"))] +#[path = "reqwest_backend"] +mod backend { + pub mod buildomat_builder; + pub mod buildomat_builder_tagged; + pub mod buildomat_cli; + pub mod buildomat_httpmock; + pub mod buildomat_positional; + pub mod cli_gen_builder; + pub mod cli_gen_builder_tagged; + pub mod cli_gen_cli; + pub mod cli_gen_httpmock; + pub mod cli_gen_positional; + pub mod keeper_builder; + pub mod keeper_builder_tagged; + pub mod keeper_cli; + pub mod keeper_httpmock; + pub mod keeper_positional; + pub mod nexus_builder; + pub mod nexus_builder_tagged; + pub mod nexus_cli; + pub mod nexus_httpmock; + pub mod nexus_positional; + pub mod param_collision_builder; + pub mod param_collision_builder_tagged; + pub mod param_collision_cli; + pub mod param_collision_httpmock; + pub mod param_collision_positional; + pub mod param_overrides_builder; + pub mod param_overrides_builder_tagged; + pub mod param_overrides_cli; + pub mod param_overrides_httpmock; + pub mod param_overrides_positional; + pub mod propolis_server_builder; + pub mod propolis_server_builder_tagged; + pub mod propolis_server_cli; + pub mod propolis_server_httpmock; + pub mod propolis_server_positional; + pub mod test_default_params_builder; + pub mod test_default_params_positional; + pub mod test_freeform_response; + pub mod test_renamed_parameters; +} + +#[cfg(target_arch = "wasm32")] +#[path = "gloo_backend"] +mod backend { + pub mod buildomat_builder; + pub mod buildomat_builder_tagged; + pub mod buildomat_positional; + pub mod cli_gen_builder; + pub mod cli_gen_builder_tagged; + pub mod cli_gen_positional; + pub mod keeper_builder; + pub mod keeper_builder_tagged; + pub mod keeper_positional; + pub mod nexus_builder; + pub mod nexus_builder_tagged; + pub mod nexus_positional; + pub mod param_collision_builder; + pub mod param_collision_builder_tagged; + pub mod param_collision_positional; + pub mod param_overrides_builder; + pub mod param_overrides_builder_tagged; + pub mod param_overrides_positional; + pub mod propolis_server_builder; + pub mod propolis_server_builder_tagged; + pub mod propolis_server_positional; +} + +pub use backend::*; diff --git a/progenitor-impl/tests/output/src/buildomat_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/buildomat_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/buildomat_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/buildomat_builder.rs diff --git a/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/buildomat_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/buildomat_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/buildomat_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/buildomat_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/buildomat_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/buildomat_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/buildomat_cli.rs diff --git a/progenitor-impl/tests/output/src/buildomat_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/buildomat_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/buildomat_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/buildomat_httpmock.rs diff --git a/progenitor-impl/tests/output/src/buildomat_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/buildomat_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/buildomat_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/buildomat_positional.rs diff --git a/progenitor-impl/tests/output/src/cli_gen_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/cli_gen_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/cli_gen_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/cli_gen_builder.rs diff --git a/progenitor-impl/tests/output/src/cli_gen_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/cli_gen_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/cli_gen_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/cli_gen_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/cli_gen_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/cli_gen_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/cli_gen_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/cli_gen_cli.rs diff --git a/progenitor-impl/tests/output/src/cli_gen_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/cli_gen_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/cli_gen_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/cli_gen_httpmock.rs diff --git a/progenitor-impl/tests/output/src/cli_gen_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/cli_gen_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/cli_gen_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/cli_gen_positional.rs diff --git a/progenitor-impl/tests/output/src/keeper_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/keeper_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/keeper_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/keeper_builder.rs diff --git a/progenitor-impl/tests/output/src/keeper_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/keeper_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/keeper_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/keeper_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/keeper_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/keeper_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/keeper_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/keeper_cli.rs diff --git a/progenitor-impl/tests/output/src/keeper_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/keeper_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/keeper_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/keeper_httpmock.rs diff --git a/progenitor-impl/tests/output/src/keeper_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/keeper_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/keeper_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/keeper_positional.rs diff --git a/progenitor-impl/tests/output/src/nexus_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_builder.rs diff --git a/progenitor-impl/tests/output/src/nexus_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/nexus_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_cli.rs diff --git a/progenitor-impl/tests/output/src/nexus_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_httpmock.rs diff --git a/progenitor-impl/tests/output/src/nexus_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_positional.rs diff --git a/progenitor-impl/tests/output/src/nexus_with_timeout.rs b/progenitor-impl/tests/output/src/reqwest_backend/nexus_with_timeout.rs similarity index 100% rename from progenitor-impl/tests/output/src/nexus_with_timeout.rs rename to progenitor-impl/tests/output/src/reqwest_backend/nexus_with_timeout.rs diff --git a/progenitor-impl/tests/output/src/param_collision_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_collision_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_collision_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_collision_builder.rs diff --git a/progenitor-impl/tests/output/src/param_collision_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_collision_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_collision_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_collision_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/param_collision_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_collision_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_collision_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_collision_cli.rs diff --git a/progenitor-impl/tests/output/src/param_collision_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_collision_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_collision_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_collision_httpmock.rs diff --git a/progenitor-impl/tests/output/src/param_collision_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_collision_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_collision_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_collision_positional.rs diff --git a/progenitor-impl/tests/output/src/param_overrides_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_overrides_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_overrides_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_overrides_builder.rs diff --git a/progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_overrides_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_overrides_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/param_overrides_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_overrides_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_overrides_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_overrides_cli.rs diff --git a/progenitor-impl/tests/output/src/param_overrides_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_overrides_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_overrides_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_overrides_httpmock.rs diff --git a/progenitor-impl/tests/output/src/param_overrides_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/param_overrides_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/param_overrides_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/param_overrides_positional.rs diff --git a/progenitor-impl/tests/output/src/propolis_server_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/propolis_server_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/propolis_server_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/propolis_server_builder.rs diff --git a/progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs b/progenitor-impl/tests/output/src/reqwest_backend/propolis_server_builder_tagged.rs similarity index 100% rename from progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs rename to progenitor-impl/tests/output/src/reqwest_backend/propolis_server_builder_tagged.rs diff --git a/progenitor-impl/tests/output/src/propolis_server_cli.rs b/progenitor-impl/tests/output/src/reqwest_backend/propolis_server_cli.rs similarity index 100% rename from progenitor-impl/tests/output/src/propolis_server_cli.rs rename to progenitor-impl/tests/output/src/reqwest_backend/propolis_server_cli.rs diff --git a/progenitor-impl/tests/output/src/propolis_server_httpmock.rs b/progenitor-impl/tests/output/src/reqwest_backend/propolis_server_httpmock.rs similarity index 100% rename from progenitor-impl/tests/output/src/propolis_server_httpmock.rs rename to progenitor-impl/tests/output/src/reqwest_backend/propolis_server_httpmock.rs diff --git a/progenitor-impl/tests/output/src/propolis_server_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/propolis_server_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/propolis_server_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/propolis_server_positional.rs diff --git a/progenitor-impl/tests/output/src/test_default_params_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_default_params_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_default_params_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_default_params_builder.rs diff --git a/progenitor-impl/tests/output/src/test_default_params_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_default_params_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_default_params_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_default_params_positional.rs diff --git a/progenitor-impl/tests/output/src/test_freeform_response.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_freeform_response.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_freeform_response.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_freeform_response.rs diff --git a/progenitor-impl/tests/output/src/test_renamed_parameters.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_renamed_parameters.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_renamed_parameters.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_renamed_parameters.rs diff --git a/progenitor-impl/tests/output/src/test_stream_pagination_builder.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_stream_pagination_builder.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_stream_pagination_builder.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_stream_pagination_builder.rs diff --git a/progenitor-impl/tests/output/src/test_stream_pagination_positional.rs b/progenitor-impl/tests/output/src/reqwest_backend/test_stream_pagination_positional.rs similarity index 100% rename from progenitor-impl/tests/output/src/test_stream_pagination_positional.rs rename to progenitor-impl/tests/output/src/reqwest_backend/test_stream_pagination_positional.rs diff --git a/progenitor-impl/tests/test_output.rs b/progenitor-impl/tests/test_output.rs index 010315d9..6e57a722 100644 --- a/progenitor-impl/tests/test_output.rs +++ b/progenitor-impl/tests/test_output.rs @@ -53,7 +53,16 @@ fn verify_apis(openapi_file: &str) { let mut generator = Generator::default(); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}_positional.rs", openapi_stem), + format!("tests/output/src/reqwest_backend/{}_positional.rs", openapi_stem), + &output, + ); + + let mut generator = Generator::new( + GenerationSettings::default().with_backend(progenitor_impl::HttpBackend::Gloo), + ); + let output = generate_formatted(&mut generator, &spec); + expectorate::assert_contents( + format!("tests/output/src/gloo_backend/{}_positional.rs", openapi_stem), &output, ); @@ -76,7 +85,30 @@ fn verify_apis(openapi_file: &str) { ); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}_builder.rs", openapi_stem), + format!("tests/output/src/reqwest_backend/{}_builder.rs", openapi_stem), + &output, + ); + + let mut generator = Generator::new( + GenerationSettings::default() + .with_backend(progenitor_impl::HttpBackend::Gloo) + .with_interface(InterfaceStyle::Builder) + .with_tag(TagStyle::Merged) + .with_derive("schemars::JsonSchema") + .with_patch("Name", TypePatch::default().with_derive("Hash")) + .with_conversion( + schemars::schema::SchemaObject { + instance_type: Some(schemars::schema::InstanceType::Integer.into()), + format: Some("int32".to_string()), + ..Default::default() + }, + "usize", + [TypeImpl::Display].into_iter(), + ), + ); + let output = generate_formatted(&mut generator, &spec); + expectorate::assert_contents( + format!("tests/output/src/gloo_backend/{}_builder.rs", openapi_stem), &output, ); @@ -89,7 +121,20 @@ fn verify_apis(openapi_file: &str) { ); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}_builder_tagged.rs", openapi_stem), + format!("tests/output/src/reqwest_backend/{}_builder_tagged.rs", openapi_stem), + &output, + ); + + let mut generator = Generator::new( + GenerationSettings::default() + .with_backend(progenitor_impl::HttpBackend::Gloo) + .with_interface(InterfaceStyle::Builder) + .with_cli_bounds("std::clone::Clone") + .with_tag(TagStyle::Separate), + ); + let output = generate_formatted(&mut generator, &spec); + expectorate::assert_contents( + format!("tests/output/src/gloo_backend/{}_builder_tagged.rs", openapi_stem), &output, ); @@ -99,7 +144,7 @@ fn verify_apis(openapi_file: &str) { .unwrap(); let output = reformat_code(tokens); - expectorate::assert_contents(format!("tests/output/src/{}_cli.rs", openapi_stem), &output); + expectorate::assert_contents(format!("tests/output/src/reqwest_backend/{}_cli.rs", openapi_stem), &output); // httpmock generation. let code = generator @@ -118,7 +163,7 @@ fn verify_apis(openapi_file: &str) { let output = progenitor_impl::space_out_items(output).unwrap(); expectorate::assert_contents( - format!("tests/output/src/{}_httpmock.rs", openapi_stem), + format!("tests/output/src/reqwest_backend/{}_httpmock.rs", openapi_stem), &output, ); } diff --git a/progenitor-impl/tests/test_specific.rs b/progenitor-impl/tests/test_specific.rs index ba29aa6c..a5e16cb5 100644 --- a/progenitor-impl/tests/test_specific.rs +++ b/progenitor-impl/tests/test_specific.rs @@ -1,4 +1,4 @@ -// Copyright 2024 Oxide Computer Company +// Copyright 2025 Oxide Computer Company use dropshot::{ endpoint, ApiDescription, Body, ConfigDropshot, ConfigLogging, ConfigLoggingLevel, @@ -81,7 +81,7 @@ fn test_renamed_parameters() { let mut generator = Generator::default(); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}.rs", "test_renamed_parameters"), + format!("tests/output/src/reqwest_backend/{}.rs", "test_renamed_parameters"), &output, ) } @@ -112,7 +112,7 @@ fn test_freeform_response() { let mut generator = Generator::default(); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}.rs", "test_freeform_response"), + format!("tests/output/src/reqwest_backend/{}.rs", "test_freeform_response"), &output, ) } @@ -166,7 +166,7 @@ fn test_default_params() { let mut generator = Generator::default(); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}.rs", "test_default_params_positional"), + format!("tests/output/src/reqwest_backend/{}.rs", "test_default_params_positional"), &output, ); @@ -174,7 +174,7 @@ fn test_default_params() { Generator::new(GenerationSettings::default().with_interface(InterfaceStyle::Builder)); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{}.rs", "test_default_params_builder"), + format!("tests/output/src/reqwest_backend/{}.rs", "test_default_params_builder"), &output, ); } @@ -237,13 +237,13 @@ async fn test_stream_pagination() { Generator::new(GenerationSettings::new().with_interface(InterfaceStyle::Positional)); let output = generate_formatted(&mut generator, &spec); expectorate::assert_contents( - format!("tests/output/src/{TEST_NAME}_positional.rs"), + format!("tests/output/src/reqwest_backend/{TEST_NAME}_positional.rs"), &output, ); let mut generator = Generator::new(GenerationSettings::new().with_interface(InterfaceStyle::Builder)); let output = generate_formatted(&mut generator, &spec); - expectorate::assert_contents(format!("tests/output/src/{TEST_NAME}_builder.rs"), &output); + expectorate::assert_contents(format!("tests/output/src/reqwest_backend/{TEST_NAME}_builder.rs"), &output); // Run the Dropshot server. let config_dropshot = ConfigDropshot { @@ -278,7 +278,7 @@ async fn test_stream_pagination() { // `EXPECTORATE=overwrite`, because the above check will overwrite the // file on disk, but then the test proceeds and gets to this point, // where it uses what was on disk _before_ expectorate overwrote it. - include!("output/src/test_stream_pagination_positional.rs"); + include!("output/src/reqwest_backend/test_stream_pagination_positional.rs"); } let client = gen_client_positional::Client::new(&server_addr); @@ -323,7 +323,7 @@ async fn test_stream_pagination() { // `EXPECTORATE=overwrite`, because the above check will overwrite the // file on disk, but then the test proceeds and gets to this point, // where it uses what was on disk _before_ expectorate overwrote it. - include!("output/src/test_stream_pagination_builder.rs"); + include!("output/src/reqwest_backend/test_stream_pagination_builder.rs"); } let client = gen_client_builder::Client::new(&server_addr); diff --git a/progenitor/src/lib.rs b/progenitor/src/lib.rs index 52cd7b3b..960a0965 100644 --- a/progenitor/src/lib.rs +++ b/progenitor/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2024 Oxide Computer Company +// Copyright 2025 Oxide Computer Company //! Progenitor is a Rust crate for generating opinionated clients from API //! descriptions specified in the OpenAPI 3.0.x format. It makes use of Rust @@ -18,6 +18,7 @@ pub use progenitor_impl::CrateVers; pub use progenitor_impl::Error; pub use progenitor_impl::GenerationSettings; pub use progenitor_impl::Generator; +pub use progenitor_impl::HttpBackend; pub use progenitor_impl::InterfaceStyle; pub use progenitor_impl::TagStyle; pub use progenitor_impl::TypeImpl;