From 9b28ac87c62873a5d16e765697a5953e37457904 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Sat, 2 Jul 2022 19:09:38 -0700 Subject: [PATCH] add an optional builder pattern as well as extension traits for tags when using the builder interface (#86) --- .github/workflows/rust.yml | 28 + CHANGELOG.adoc | 4 +- Cargo.lock | 120 +- Cargo.toml | 6 +- README.md | 14 +- example-build/Cargo.toml | 2 +- example-build/build.rs | 2 +- example-macro/Cargo.toml | 2 +- progenitor-client/Cargo.toml | 2 +- progenitor-client/src/progenitor_client.rs | 2 + progenitor-impl/Cargo.toml | 6 +- progenitor-impl/src/lib.rs | 216 +- progenitor-impl/src/method.rs | 1015 +- progenitor-impl/src/template.rs | 14 +- .../tests/output/buildomat-builder-tagged.out | 1186 ++ .../tests/output/buildomat-builder.out | 1186 ++ ...buildomat.out => buildomat-positional.out} | 74 +- .../tests/output/keeper-builder-tagged.out | 418 + .../tests/output/keeper-builder.out | 418 + .../{keeper.out => keeper-positional.out} | 28 +- .../tests/output/nexus-builder-tagged.out | 13071 ++++++++++++++++ .../tests/output/nexus-builder.out | 12852 +++++++++++++++ .../{nexus.out => nexus-positional.out} | 2219 ++- .../tests/output/test_default_params.out | 14 +- .../tests/output/test_freeform_response.out | 12 +- .../tests/output/test_renamed_parameters.out | 18 +- progenitor-impl/tests/test_output.rs | 45 +- progenitor-impl/tests/test_specific.rs | 12 +- progenitor-macro/Cargo.toml | 2 +- progenitor-macro/src/lib.rs | 98 +- progenitor/Cargo.toml | 6 +- progenitor/src/lib.rs | 3 + progenitor/src/main.rs | 93 +- progenitor/tests/build_buildomat.rs | 42 +- progenitor/tests/build_keeper.rs | 49 +- progenitor/tests/build_nexus.rs | 83 +- 36 files changed, 32268 insertions(+), 1094 deletions(-) create mode 100644 progenitor-impl/tests/output/buildomat-builder-tagged.out create mode 100644 progenitor-impl/tests/output/buildomat-builder.out rename progenitor-impl/tests/output/{buildomat.out => buildomat-positional.out} (86%) create mode 100644 progenitor-impl/tests/output/keeper-builder-tagged.out create mode 100644 progenitor-impl/tests/output/keeper-builder.out rename progenitor-impl/tests/output/{keeper.out => keeper-positional.out} (88%) create mode 100644 progenitor-impl/tests/output/nexus-builder-tagged.out create mode 100644 progenitor-impl/tests/output/nexus-builder.out rename progenitor-impl/tests/output/{nexus.out => nexus-positional.out} (71%) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9712afe..c26bb1e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,10 +14,26 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 + - name: Install nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: rustfmt + default: false + - name: Install stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt + default: true - name: Report cargo version run: cargo --version - name: Report rustfmt version run: cargo fmt -- --version + - name: Report nightly cargo version + run: cargo +nightly --version + - name: Report nightly rustfmt version + run: cargo +nightly fmt -- --version - name: Check style run: cargo fmt -- --check @@ -28,6 +44,18 @@ jobs: os: [ ubuntu-18.04, windows-2019, macos-10.15 ] steps: - uses: actions/checkout@v2 + - name: Install nightly + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: rustfmt + default: false + - name: Install stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt + default: true - name: Build run: cargo build --tests --verbose - name: Run tests diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5a1f37c..50d4df8 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -3,7 +3,7 @@ :icons: font :toclevels: 1 -= Typify Changelog += Progenitor Changelog // WARNING: This file is modified programmatically by `cargo release` as // configured in release.toml. DO NOT change the format of the headers or the @@ -15,6 +15,8 @@ https://github.com/oxidecomputer/progenitor/compare/v0.1.1\...HEAD[Full list of commits] +* Add support for a builder-style generation in addition to the positional style (#86) + == 0.1.1 (released 2022-05-13) First published version diff --git a/Cargo.lock b/Cargo.lock index 7b08a96..d15971f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,45 @@ dependencies = [ "winapi", ] +[[package]] +name = "clap" +version = "3.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "console" version = "0.15.0" @@ -776,9 +815,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.9.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "openapiv3" @@ -824,6 +863,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + [[package]] name = "parking_lot" version = "0.12.0" @@ -886,6 +931,30 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.40" @@ -901,8 +970,8 @@ version = "0.1.2-dev" dependencies = [ "anyhow", "chrono", + "clap", "futures", - "getopts", "openapiv3", "percent-encoding", "progenitor-client", @@ -1394,6 +1463,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "1.0.98" @@ -1436,6 +1511,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "terminal_size" version = "0.1.17" @@ -1446,6 +1530,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + [[package]] name = "thiserror" version = "1.0.31" @@ -1640,9 +1730,9 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "typify" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d94783d3e464d8b2b8f78e826521e9f11c7df83523dafd544c5e642bf31df5a4" +checksum = "505f18fc847efc93b45a763f36f8099d3415dbfc6c0d6c3857a3012e20db92c7" dependencies = [ "typify-impl", "typify-macro", @@ -1650,9 +1740,9 @@ dependencies = [ [[package]] name = "typify-impl" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27f7e4f8a3b375daabcd3721bc067920a59ea9a33c1f01b9b2b98d17c3b5497" +checksum = "b572369a55be8402a5a7e24c721e8d895dbd58bf3d9dccb4b3619fcb926e7bde" dependencies = [ "heck", "log", @@ -1663,14 +1753,14 @@ dependencies = [ "serde_json", "syn", "thiserror", - "unicode-xid", + "unicode-ident", ] [[package]] name = "typify-macro" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4211d794d8e4e6fed99bdcd263529ee05af52d9794004cc235123216f1fef42" +checksum = "a615bfbbcf929b1733898d2afe00c83dbf8756f8028aa42c156c3c2713b0f03b" dependencies = [ "proc-macro2", "quote", @@ -1696,9 +1786,9 @@ checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "unicode-normalization" @@ -1715,12 +1805,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - [[package]] name = "untrusted" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 775f571..da06ba3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,9 @@ members = [ "progenitor-macro", ] -#[patch."https://github.com/oxidecomputer/typify"] -#typify = { path = "../typify/typify" } #[patch."https://github.com/oxidecomputer/dropshot"] #dropshot = { path = "../dropshot/dropshot" } + +#[patch.crates-io] +#typify = { path = "../typify/typify" } +#rustfmt-wrapper = { path = "../rustfmt-wrapper" } diff --git a/README.md b/README.md index 6e0d00d..8cb7981 100644 --- a/README.md +++ b/README.md @@ -51,11 +51,13 @@ The macro has some additional fancy options to control the generated code: ```rust generate_api!( - spec = "path/to/openapi_document.json", // The OpenAPI document - inner_type = my_client::InnerType, // Client inner type available to pre and post hooks - pre_hook = closure::or::path::to::function, // Hook invoked before issuing the HTTP request - post_hook = closure::or::path::to::function, // Hook invoked prior to receiving the HTTP response - derives = [ schemars::JsonSchema ], // Additional derive macros applied to generated types + spec = "path/to/openapi_document.json", // The OpenAPI document + interface = Builder, // Choose positional (default) or builder style + tags = Separate, // Tags may be Merged or Separate (default) + inner_type = my_client::InnerType, // Client inner type available to pre and post hooks + pre_hook = closure::or::path::to::function, // Hook invoked before issuing the HTTP request + post_hook = closure::or::path::to::function, // Hook invoked prior to receiving the HTTP response + derives = [ schemars::JsonSchema ], // Additional derive macros applied to generated types ); ``` @@ -76,7 +78,7 @@ fn main() { 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::new(); + let mut generator = progenitor::Generator::default(); let content = generator.generate_text(&spec).unwrap(); diff --git a/example-build/Cargo.toml b/example-build/Cargo.toml index b2af361..17427ba 100644 --- a/example-build/Cargo.toml +++ b/example-build/Cargo.toml @@ -2,7 +2,7 @@ name = "example-build" version = "0.0.1" authors = ["Adam H. Leventhal "] -edition = "2018" +edition = "2021" [dependencies] chrono = { version = "0.4", features = ["serde"] } diff --git a/example-build/build.rs b/example-build/build.rs index b4ee9c3..ffb0ab4 100644 --- a/example-build/build.rs +++ b/example-build/build.rs @@ -11,7 +11,7 @@ fn main() { 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::new(); + let mut generator = progenitor::Generator::default(); let content = generator.generate_text(&spec).unwrap(); diff --git a/example-macro/Cargo.toml b/example-macro/Cargo.toml index 84f9ae8..68f0d47 100644 --- a/example-macro/Cargo.toml +++ b/example-macro/Cargo.toml @@ -2,7 +2,7 @@ name = "example-macro" version = "0.0.1" authors = ["Adam H. Leventhal "] -edition = "2018" +edition = "2021" [dependencies] chrono = { version = "0.4", features = ["serde"] } diff --git a/progenitor-client/Cargo.toml b/progenitor-client/Cargo.toml index 75c24e2..816a5b5 100644 --- a/progenitor-client/Cargo.toml +++ b/progenitor-client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "progenitor-client" version = "0.1.2-dev" -edition = "2018" +edition = "2021" license = "MPL-2.0" repository = "https://github.com/oxidecomputer/progenitor.git" description = "An OpenAPI client generator - client support" diff --git a/progenitor-client/src/progenitor_client.rs b/progenitor-client/src/progenitor_client.rs index 36b7d93..51014fc 100644 --- a/progenitor-client/src/progenitor_client.rs +++ b/progenitor-client/src/progenitor_client.rs @@ -1,5 +1,7 @@ // Copyright 2022 Oxide Computer Company +#![allow(dead_code)] + //! Support code for generated clients. use std::{ diff --git a/progenitor-impl/Cargo.toml b/progenitor-impl/Cargo.toml index 963485f..4f9b87d 100644 --- a/progenitor-impl/Cargo.toml +++ b/progenitor-impl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "progenitor-impl" version = "0.1.2-dev" -edition = "2018" +edition = "2021" license = "MPL-2.0" repository = "https://github.com/oxidecomputer/progenitor.git" description = "An OpenAPI client generator - core implementation" @@ -14,13 +14,13 @@ openapiv3 = "1.0.0" proc-macro2 = "1.0" quote = "1.0" regex = "1.5" -rustfmt-wrapper = "0.2" +rustfmt-wrapper = "0.2.0" schemars = { version = "0.8.10", features = ["chrono", "uuid1"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" syn = { version = "1.0", features = ["parsing"] } thiserror = "1.0" -typify = "0.0.8" +typify = "0.0.9" unicode-ident = "1.0.0" [dev-dependencies] diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index 11dbc36..0439a54 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -3,6 +3,7 @@ use openapiv3::OpenAPI; use proc_macro2::TokenStream; use quote::quote; +use serde::Deserialize; use thiserror::Error; use typify::TypeSpace; @@ -32,17 +33,59 @@ pub type Result = std::result::Result; #[derive(Default)] pub struct Generator { type_space: TypeSpace, - inner_type: Option, - pre_hook: Option, - post_hook: Option, + settings: GenerationSettings, uses_futures: bool, } -impl Generator { +#[derive(Default, Clone)] +pub struct GenerationSettings { + interface: InterfaceStyle, + tag: TagStyle, + inner_type: Option, + pre_hook: Option, + post_hook: Option, + extra_derives: Vec, +} + +#[derive(Clone, Deserialize)] +pub enum InterfaceStyle { + Positional, + Builder, +} + +impl Default for InterfaceStyle { + fn default() -> Self { + Self::Positional + } +} + +#[derive(Clone, Deserialize)] +pub enum TagStyle { + Merged, + Separate, +} + +impl Default for TagStyle { + fn default() -> Self { + Self::Merged + } +} + +impl GenerationSettings { pub fn new() -> Self { Self::default() } + pub fn with_interface(&mut self, interface: InterfaceStyle) -> &mut Self { + self.interface = interface; + self + } + + pub fn with_tag(&mut self, tag: TagStyle) -> &mut Self { + self.tag = tag; + self + } + pub fn with_inner_type(&mut self, inner_type: TokenStream) -> &mut Self { self.inner_type = Some(inner_type); self @@ -58,10 +101,21 @@ impl Generator { self } + // TODO maybe change to a typify::Settings or something pub fn with_derive(&mut self, derive: TokenStream) -> &mut Self { - self.type_space.add_derive(derive); + self.extra_derives.push(derive); self } +} + +impl Generator { + pub fn new(settings: &GenerationSettings) -> Self { + Self { + type_space: TypeSpace::default(), + settings: settings.clone(), + uses_futures: false, + } + } pub fn generate_tokens(&mut self, spec: &OpenAPI) -> Result { // Convert our components dictionary to schemars @@ -100,10 +154,23 @@ impl Generator { }) .collect::>>()?; - let methods = raw_methods - .iter() - .map(|method| self.positional_method(method)) - .collect::>>()?; + let operation_code = match ( + &self.settings.interface, + &self.settings.tag, + ) { + (InterfaceStyle::Positional, TagStyle::Merged) => { + self.generate_tokens_positional_merged(&raw_methods) + } + (InterfaceStyle::Positional, TagStyle::Separate) => { + unimplemented!("positional arguments with separate tags are currently unsupported") + } + (InterfaceStyle::Builder, TagStyle::Merged) => { + self.generate_tokens_builder_merged(&raw_methods) + } + (InterfaceStyle::Builder, TagStyle::Separate) => { + self.generate_tokens_builder_separate(&raw_methods) + } + }?; let mut types = self .type_space @@ -114,12 +181,17 @@ impl Generator { let types = types.into_iter().map(|(_, def)| def); let shared = self.type_space.common_code(); - let inner_property = self.inner_type.as_ref().map(|inner| { + let inner_property = self.settings.inner_type.as_ref().map(|inner| { + quote! { + pub (crate) inner: #inner, + } + }); + let inner_parameter = self.settings.inner_type.as_ref().map(|inner| { quote! { inner: #inner, } }); - let inner_value = self.inner_type.as_ref().map(|_| { + let inner_value = self.settings.inner_type.as_ref().map(|_| { quote! { inner } @@ -129,6 +201,8 @@ impl Generator { // Re-export ResponseValue and Error since those are used by the // public interface of Client. pub use progenitor_client::{ByteStream, Error, ResponseValue}; + #[allow(unused_imports)] + use progenitor_client::encode_path; pub mod types { use serde::{Deserialize, Serialize}; @@ -138,15 +212,15 @@ impl Generator { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, #inner_property } impl Client { pub fn new( baseurl: &str, - #inner_property + #inner_parameter ) -> Self { let dur = std::time::Duration::from_secs(15); let client = reqwest::ClientBuilder::new() @@ -160,7 +234,7 @@ impl Generator { pub fn new_with_client( baseurl: &str, client: reqwest::Client, - #inner_property + #inner_parameter ) -> Self { Self { baseurl: baseurl.to_string(), @@ -177,18 +251,126 @@ impl Generator { &self.client } - #(#methods)* } + + #operation_code }; Ok(file) } + fn generate_tokens_positional_merged( + &mut self, + input_methods: &[method::OperationMethod], + ) -> Result { + let methods = input_methods + .iter() + .map(|method| self.positional_method(method)) + .collect::>>()?; + let out = quote! { + impl Client { + #(#methods)* + } + }; + Ok(out) + } + + fn generate_tokens_builder_merged( + &mut self, + input_methods: &[method::OperationMethod], + ) -> Result { + let builder_struct = input_methods + .iter() + .map(|method| self.builder_struct(method, TagStyle::Merged)) + .collect::>>()?; + + let builder_methods = input_methods + .iter() + .map(|method| self.builder_impl(method)) + .collect::>(); + + let out = quote! { + impl Client { + #(#builder_methods)* + } + + pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + #[allow(unused_imports)] + use super::encode_path; + + #(#builder_struct)* + } + }; + + Ok(out) + } + + fn generate_tokens_builder_separate( + &mut self, + input_methods: &[method::OperationMethod], + ) -> Result { + let builder_struct = input_methods + .iter() + .map(|method| self.builder_struct(method, TagStyle::Separate)) + .collect::>>()?; + + let traits_and_impls = self.builder_tags(input_methods); + + let out = quote! { + #traits_and_impls + + pub mod builder { + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + #[allow(unused_imports)] + use super::encode_path; + + #(#builder_struct)* + } + }; + + Ok(out) + } + + /// Render text output. pub fn generate_text(&mut self, spec: &OpenAPI) -> Result { + self.generate_text_impl( + spec, + rustfmt_wrapper::config::Config::default(), + ) + } + + /// Render text output and normalize doc comments + /// + /// Requires a nightly install of `rustfmt` (even if the target project is + /// not using nightly). + pub fn generate_text_normalize_comments( + &mut self, + spec: &OpenAPI, + ) -> Result { + self.generate_text_impl( + spec, + rustfmt_wrapper::config::Config { + normalize_doc_attributes: Some(true), + wrap_comments: Some(true), + ..Default::default() + }, + ) + } + + fn generate_text_impl( + &mut self, + spec: &OpenAPI, + config: rustfmt_wrapper::config::Config, + ) -> Result { let output = self.generate_tokens(spec)?; // Format the file with rustfmt. - let content = rustfmt_wrapper::rustfmt(output).unwrap(); + let content = rustfmt_wrapper::rustfmt_config(config, output).unwrap(); // Add newlines after end-braces at <= two levels of indentation. Ok(if cfg!(not(windows)) { diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index 7fc0758..50ed518 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -2,7 +2,7 @@ use std::{ cmp::Ordering, - collections::{BTreeSet, HashMap}, + collections::{BTreeMap, BTreeSet}, str::FromStr, }; @@ -14,13 +14,14 @@ use typify::TypeId; use crate::{ template::PathTemplate, util::{sanitize, Case}, - Error, Generator, Result, + Error, Generator, Result, TagStyle, }; use crate::{to_schema::ToSchema, util::ReferenceOrExt}; /// The intermediate representation of an operation that will become a method. pub(crate) struct OperationMethod { operation_id: String, + pub tags: Vec, method: HttpMethod, path: PathTemplate, summary: Option, @@ -74,6 +75,18 @@ impl HttpMethod { } } +struct MethodSigBody { + success: TokenStream, + error: TokenStream, + body: TokenStream, +} + +struct BuilderImpl { + doc: String, + sig: TokenStream, + body: TokenStream, +} + struct DropshotPagination { item: TypeId, } @@ -94,6 +107,7 @@ struct OperationParameter { kind: OperationParameterKind, } +#[derive(Eq, PartialEq)] enum OperationParameterType { Type(TypeId), RawBody, @@ -449,6 +463,7 @@ impl Generator { Ok(OperationMethod { operation_id: sanitize(operation_id, Case::Snake), + tags: operation.tags.clone(), method: HttpMethod::from_str(method)?, path: tmp, summary: operation.summary.clone().filter(|s| !s.is_empty()), @@ -497,6 +512,167 @@ impl Generator { quote! { <'a> } }; + let doc_comment = make_doc_comment(method); + + let MethodSigBody { + success: success_type, + error: error_type, + body, + } = self.method_sig_body(method, quote! { self })?; + + let method_impl = quote! { + #[doc = #doc_comment] + pub async fn #operation_id #bounds ( + &'a self, + #(#params),* + ) -> Result< + ResponseValue<#success_type>, + Error<#error_type>, + > { + #body + } + }; + + let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { + // We're now using futures. + self.uses_futures = true; + + let stream_id = format_ident!("{}_stream", method.operation_id); + + // The parameters are the same as those to the paged method, but + // without "page_token" + let stream_params = method.params.iter().zip(params).filter_map( + |(param, stream)| { + if param.name.as_str() == "page_token" { + None + } else { + Some(stream) + } + }, + ); + + // The values passed to get the first page are the inputs to the + // stream method with "None" for the page_token. + let first_params = method.params.iter().map(|param| { + if param.api_name.as_str() == "page_token" { + // The page_token is None when getting the first page. + quote! { None } + } else { + // All other parameters are passed through directly. + format_ident!("{}", param.name).to_token_stream() + } + }); + + // The values passed to get subsequent pages are... + // - the state variable for the page_token + // - None for all other query parameters + // - The initial inputs for non-query parameters + let step_params = method.params.iter().map(|param| { + if param.api_name.as_str() == "page_token" { + quote! { state.as_deref() } + } else if let OperationParameterKind::Query(_) = param.kind { + // Query parameters are None; having page_token as Some(_) + // is mutually exclusive with other query parameters. + quote! { None } + } else { + // Non-query parameters are passed in; this is necessary + // e.g. to specify the right path. (We don't really expect + // to see a body parameter here, but we pass it through + // regardless.) + format_ident!("{}", param.name).to_token_stream() + } + }); + + // The item type that we've saved (by picking apart the original + // function's return type) will be the Item type parameter for the + // Stream type we return. + let item = self.type_space.get_type(&page_data.item).unwrap(); + let item_type = item.ident(); + + let doc_comment = make_stream_doc_comment(method); + + quote! { + #[doc = #doc_comment] + pub fn #stream_id #bounds ( + &'a self, + #(#stream_params),* + ) -> impl futures::Stream, + >> + Unpin + '_ { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + + // Execute the operation with the basic parameters + // (omitting page_token) to get the first page. + self.#operation_id( #(#first_params,)* ) + .map_ok(move |page| { + let page = page.into_inner(); + + // Create a stream from the items of the first page. + let first = futures::stream::iter( + page.items.into_iter().map(Ok) + ); + + // We unfold subsequent pages using page.next_page + // as the seed value. Each iteration returns its + // items and the next page token. + let rest = futures::stream::try_unfold( + page.next_page, + move |state| async move { + if state.is_none() { + // The page_token was None so we've + // reached the end. + Ok(None) + } else { + // Get the next page; here we set all + // query parameters to None (except for + // the page_token), and all other + // parameters as specified at the start + // of this method. + self.#operation_id( + #(#step_params,)* + ) + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter( + page + .items + .into_iter() + .map(Ok), + ), + page.next_page, + )) + }) + .await + } + }, + ) + .try_flatten(); + + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + }); + + let all = quote! { + #method_impl + #stream_impl + }; + + Ok(all) + } + + fn method_sig_body( + &self, + method: &OperationMethod, + client: TokenStream, + ) -> Result { // Generate code for query parameters. let query_items = method .params @@ -546,14 +722,14 @@ impl Generator { _ => None, }) .collect(); - let url_path = method.path.compile(url_renames); + let url_path = method.path.compile(url_renames, client.clone()); // Generate code to handle the body... let body_func = method.params.iter().filter_map(|param| match ¶m.kind { OperationParameterKind::Body => match ¶m.typ { OperationParameterType::Type(_) => { - Some(quote! { .json(body) }) + Some(quote! { .json(&body) }) } OperationParameterType::RawBody => { Some(quote! { .body(body) }) @@ -662,216 +838,77 @@ impl Generator { _ => quote! { _ => Err(Error::UnexpectedResponse(response)), }, }; - let doc_comment = make_doc_comment(method); - - let pre_hook = self.pre_hook.as_ref().map(|hook| { + let pre_hook = self.settings.pre_hook.as_ref().map(|hook| { quote! { - (#hook)(&self.inner, &request); + (#hook)(&#client.inner, &request); } }); - let post_hook = self.post_hook.as_ref().map(|hook| { + let post_hook = self.settings.post_hook.as_ref().map(|hook| { quote! { - (#hook)(&self.inner, &result); + (#hook)(&#client.inner, &result); } }); let method_func = format_ident!("{}", method.method.as_str()); - let method_impl = quote! { - #[doc = #doc_comment] - pub async fn #operation_id #bounds ( - &'a self, - #(#params),* - ) -> Result< - ResponseValue<#response_type>, - Error<#error_type>, - > { - #url_path - #query_build + let body_impl = quote! { + #url_path + #query_build - let request = self.client - . #method_func (url) - #(#body_func)* - #query_use - .build()?; - #pre_hook - let result = self.client - .execute(request) - .await; - #post_hook + let request = #client.client + . #method_func (url) + #(#body_func)* + #query_use + .build()?; + #pre_hook + let result = #client.client + .execute(request) + .await; + #post_hook - let response = result?; + let response = result?; - match response.status().as_u16() { - // These will be of the form... - // 201 => ResponseValue::from_response(response).await, - // 200..299 => ResponseValue::empty(response), - // TODO this kind of enumerated response isn't implemented - // ... or in the case of an operation with multiple - // successful response types... - // 200 => { - // ResponseValue::from_response() - // .await? - // .map(OperationXResponse::ResponseTypeA) - // } - // 201 => { - // ResponseValue::from_response() - // .await? - // .map(OperationXResponse::ResponseTypeB) - // } - #(#success_response_matches)* + match response.status().as_u16() { + // These will be of the form... + // 201 => ResponseValue::from_response(response).await, + // 200..299 => ResponseValue::empty(response), + // TODO this kind of enumerated response isn't implemented + // ... or in the case of an operation with multiple + // successful response types... + // 200 => { + // ResponseValue::from_response() + // .await? + // .map(OperationXResponse::ResponseTypeA) + // } + // 201 => { + // ResponseValue::from_response() + // .await? + // .map(OperationXResponse::ResponseTypeB) + // } + #(#success_response_matches)* - // This is almost identical to the success types except - // they are wrapped in Error::ErrorResponse... - // 400 => { - // Err(Error::ErrorResponse( - // ResponseValue::from_response(response.await?) - // )) - // } - #(#error_response_matches)* + // This is almost identical to the success types except + // they are wrapped in Error::ErrorResponse... + // 400 => { + // Err(Error::ErrorResponse( + // ResponseValue::from_response(response.await?) + // )) + // } + #(#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 } }; - let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { - // We're now using futures. - self.uses_futures = true; - - let stream_id = format_ident!("{}_stream", method.operation_id); - - // The parameters are the same as those to the paged method, but - // without "page_token" - let stream_params = method.params.iter().zip(params).filter_map( - |(param, stream)| { - if param.name.as_str() == "page_token" { - None - } else { - Some(stream) - } - }, - ); - - // The values passed to get the first page are the inputs to the - // stream method with "None" for the page_token. - let first_params = method.params.iter().map(|param| { - if param.api_name.as_str() == "page_token" { - // The page_token is None when getting the first page. - quote! { None } - } else { - // All other parameters are passed through directly. - format_ident!("{}", param.name).to_token_stream() - } - }); - - // The values passed to get subsequent pages are... - // - the state variable for the page_token - // - None for all other query parameters - // - The method inputs for non-query parameters - let step_params = method.params.iter().map(|param| { - if param.api_name.as_str() == "page_token" { - quote! { state.as_deref() } - } else if let OperationParameterKind::Query(_) = param.kind { - // Query parameters are None; having page_token as Some(_) - // is mutually exclusive with other query parameters. - quote! { None } - } else { - // Non-query parameters are passed in; this is necessary - // e.g. to specify the right path. (We don't really expect - // to see a body parameter here, but we pass it through - // regardless.) - format_ident!("{}", param.name).to_token_stream() - } - }); - - // The item type that we've saved (by picking apart the original - // function's return type) will be the Item type parameter for the - // Stream type we return. - let item = self.type_space.get_type(&page_data.item).unwrap(); - let item_type = item.ident(); - - let doc_comment = make_stream_doc_comment(method); - - quote! { - #[doc = #doc_comment] - pub fn #stream_id #bounds ( - &'a self, - #(#stream_params),* - ) -> impl futures::Stream, - >> + Unpin + '_ { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - - // Execute the operation with the basic parameters - // (omitting page_token) to get the first page. - self.#operation_id( - #(#first_params,)* - ) - .map_ok(move |page| { - let page = page.into_inner(); - // The first page is just an iter - let first = futures::stream::iter( - page.items.into_iter().map(Ok) - ); - - // We unfold subsequent pages using page.next_page as - // the seed value. Each iteration returns its items and - // the next page token. - let rest = futures::stream::try_unfold( - page.next_page, - move |state| async move { - if state.is_none() { - // The page_token was None so we've reached - // the end. - Ok(None) - } else { - // Get the next page; here we set all query - // parameters to None (except for the - // page_token), and all other parameters as - // specified at the start of this method. - self.#operation_id( - #(#step_params,)* - ) - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter( - page - .items - .into_iter() - .map(Ok), - ), - page.next_page, - )) - }) - .await - } - }, - ) - .try_flatten(); - - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - }); - - let all = quote! { - #method_impl - #stream_impl - }; - - Ok(all) + Ok(MethodSigBody { + success: response_type, + error: error_type, + body: body_impl, + }) } fn extract_responses<'a>( @@ -960,8 +997,8 @@ impl Generator { .filter(|param| { matches!( (param.api_name.as_str(), ¶m.kind), - ("page_token", OperationParameterKind::Query(_)) - | ("limit", OperationParameterKind::Query(_)) + ("page_token", OperationParameterKind::Query(false)) + | ("limit", OperationParameterKind::Query(false)) ) }) .count() @@ -979,6 +1016,17 @@ impl Generator { return None; } + // A raw body parameter can only be passed to a single call as it may + // be a streaming type. We can't use a streaming type for a paginated + // interface because we can only stream it once rather than for the + // multiple calls required to collect all pages. + if parameters + .iter() + .any(|param| param.typ == OperationParameterType::RawBody) + { + return None; + } + // There must be exactly one successful response type. let mut success_response_items = responses.iter().filter_map(|response| { @@ -1006,7 +1054,7 @@ impl Generator { _ => return None, }; - let properties = details.properties().collect::>(); + let properties = details.properties().collect::>(); // There should be exactly two properties: items and next_page if properties.len() != 2 { @@ -1022,7 +1070,7 @@ impl Generator { { if !matches!( self.type_space.get_type(opt_id).ok()?.details(), - typify::TypeDetails::Builtin("String") + typify::TypeDetails::String ) { return None; } @@ -1042,6 +1090,571 @@ impl Generator { _ => None, } } + + /// Create the builder structs along with their impls + /// + /// Builder structs are generally of this form: + /// ```ignore + /// struct OperationId<'a> { + /// client: &'a super::Client, + /// param_1: Option, + /// param_2: Option, + /// } + /// ``` + /// + /// All parameters are present and all their types are Option. Each + /// parameter also has a corresponding method: + /// ```ignore + /// impl<'a> OperationId<'a> { + /// pub fn param_1(self, value: SomeType) { + /// self.param_1 = Some(value); + /// self + /// } + /// pub fn param_2(self, value: S) { + /// self.param_2 = Some(value.into()); + /// self + /// } + /// } + /// ``` + /// + /// The Client's operation_id method simply invokes the builder's new + /// method: + /// ```ignore + /// impl<'a> OperationId<'a> { + /// pub fn new(client: &'a super::Client) -> Self { + /// Self { + /// client, + /// param_1: None, + /// param_2: None, + /// } + /// } + /// } + /// ``` + /// + /// Finally, builders have methods to execute the method, which takes care + /// to check that required parameters are specified: + /// ```ignore + /// impl<'a> OperationId<'a> { + /// pub fn send(self) -> Result< + /// ResponseValue, + /// Error, + /// > { + /// let Self { + /// client, + /// param_1, + /// param_2, + /// } = self; + /// + /// let (param_1, param_2) = match (param_1, param_2) { + /// (Some(param_1), Some(param_2)) => (param_1, param_2), + /// (param_1, param_2) => { + /// let mut missing = Vec::new(); + /// if param_1.is_none() { + /// missing.push(stringify!(param_1)); + /// } + /// if param_2.is_none() { + /// missing.push(stringify!(param_2)); + /// } + /// return Err(super::Error::InvalidRequest(format!( + /// "the following parameters are required: {}", + /// missing.join(", "), + /// ))); + /// } + /// }; + /// } + /// } + /// ``` + /// + /// Finally, paginated interfaces have a `stream()` method which uses the + /// `send()` method above to fetch each page of results to assemble the + /// items into a single impl Stream. + pub(crate) fn builder_struct( + &mut self, + method: &OperationMethod, + tag_style: TagStyle, + ) -> Result { + let mut cloneable = true; + // Generate the builder structure properties, turning each type T into + // an Option (if it isn't already). + let properties = method + .params + .iter() + .map(|param| { + let name = format_ident!("{}", param.name); + let typ = match ¶m.typ { + OperationParameterType::Type(type_id) => { + // TODO currently we explicitly turn optional paramters + // into Option types; we could probably defer this to + // the code generation step to avoid the special + // handling here. + let ty = self.type_space.get_type(type_id)?; + let t = ty.ident(); + let details = ty.details(); + if let typify::TypeDetails::Option(_) = details { + t + } else { + quote! { Option<#t> } + } + } + + OperationParameterType::RawBody => { + cloneable = false; + quote! { Option } + } + }; + + Ok(quote! { + #name: #typ + }) + }) + .collect::>>()?; + + let struct_name = sanitize(&method.operation_id, Case::Pascal); + let struct_ident = format_ident!("{}", struct_name); + + // For each parameter, we need an impl for the builder to let consumers + // provide a value for the parameter. + let property_impls = method + .params + .iter() + .map(|param| { + let param_name = format_ident!("{}", param.name); + match ¶m.typ { + OperationParameterType::Type(type_id) => { + let ty = self.type_space.get_type(type_id)?; + let x = ty.details(); + match &x { + typify::TypeDetails::String => { + Ok(quote! { + pub fn #param_name(mut self, value: S) -> Self { + self.#param_name = Some(value.to_string()); + self + } + }) + } + typify::TypeDetails::Option(ref opt_id) => { + let typ = self.type_space.get_type(opt_id)?.ident(); + Ok(quote!{ + pub fn #param_name(mut self, value: #typ) -> Self { + self.#param_name = Some(value); + self + } + }) + } + _ => { + let typ = ty.ident(); + Ok(quote! { + pub fn #param_name(mut self, value: #typ) -> Self { + self.#param_name = Some(value); + self + } + }) + } + } + } + + OperationParameterType::RawBody => { + Ok(quote! { + pub fn #param_name>(mut self, value: B) -> Self { + self.#param_name = Some(value.into()); + self + } + }) + } + } + }) + .collect::>>()?; + + let destructure = method + .params + .iter() + .map(|param| format_ident!("{}", param.name)) + .collect::>(); + + let req_names = method + .params + .iter() + .filter_map(|param| match param.kind { + OperationParameterKind::Path + | OperationParameterKind::Query(true) + | OperationParameterKind::Body => { + Some(format_ident!("{}", param.name)) + } + OperationParameterKind::Query(false) => None, + }) + .collect::>(); + + let required_extract = (!req_names.is_empty()).then(|| { + quote! { + let ( #( #req_names, )* ) = match ( #( #req_names, )* ) { + ( #( Some(#req_names), )* ) => ( #( #req_names, )* ), + ( #( #req_names, )* ) => { + let mut missing = Vec::new(); + + #( + if #req_names.is_none() { + missing.push(stringify!(#req_names)); + } + )* + + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + } + }); + + let param_props = method + .params + .iter() + .map(|param| { + let name = format_ident!("{}", param.name); + quote! { + #name: None + } + }) + .collect::>(); + + let new_impl = quote! { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + #(#param_props,)* + } + } + }; + + let MethodSigBody { + success, + error, + body, + } = self.method_sig_body(method, quote! { client})?; + + let send_doc = format!( + "Sends a `{}` request to `{}`", + method.method.as_str().to_ascii_uppercase(), + method.path.to_string(), + ); + + let send_impl = quote! { + #[doc = #send_doc] + pub async fn send(self) -> Result< + ResponseValue<#success>, + Error<#error>, + > { + // Destructure the builder for convenience. + let Self { + client, + #( #destructure ),* + } = self; + + // Extract parameters into variables, returning an error if + // a value has not been provided for all required parameters. + #required_extract + + // Do the work. + #body + } + }; + + let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { + // We're now using futures. + self.uses_futures = true; + + let step_params = method.params.iter().filter_map(|param| { + if let OperationParameterKind::Query(_) = param.kind { + let name = format_ident!("{}", param.name); + Some(quote! { + #name: None + }) + } else { + None + } + }); + + // The item type that we've saved (by picking apart the original + // function's return type) will be the Item type parameter for the + // Stream impl we return. + let item = self.type_space.get_type(&page_data.item).unwrap(); + let item_type = item.ident(); + + let stream_doc = format!( + "Streams `{}` requests to `{}`", + method.method.as_str().to_ascii_uppercase(), + method.path.to_string(), + ); + + quote! { + #[doc = #stream_doc] + pub fn stream(self) -> impl futures::Stream, + >> + Unpin + 'a { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + + // This is the builder template we'll use for iterative + // steps past the first; it has all query params set to + // None (the step will fill in page_token). + let next = Self { + #( #step_params, )* + ..self.clone() + }; + + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + + // Create a stream from the items of the first page. + let first = futures::stream::iter( + page.items.into_iter().map(Ok) + ); + + // We unfold subsequent pages using page.next_page + // as the seed value. Each iteration returns its + // items and the new state which is a tuple of the + // next page token and the Self template. + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + // The page_token was None so we've + // reached the end. + Ok(None) + } else { + // Get the next page using the next + // template (with query parameters set + // to None), overriding page_token. + Self { + page_token: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter( + page + .items + .into_iter() + .map(Ok), + ), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + }); + + let maybe_clone = cloneable.then(|| quote! { #[derive(Clone)] }); + + // Build a reasonable doc comment depending on whether this struct is + // the output from + // 1. A Client method + // 2. An extension trait method + // 3. Several extension trait methods + let struct_doc = + match (tag_style, method.tags.len(), method.tags.first()) { + (TagStyle::Merged, _, _) | (TagStyle::Separate, 0, _) => { + let ty = format!("Client::{}", method.operation_id); + format!( + "Builder for [`{}`]\n\n[`{}`]: super::{}", + ty, ty, ty, + ) + } + (TagStyle::Separate, 1, Some(tag)) => { + let ty = format!( + "Client{}Ext::{}", + sanitize(tag, Case::Pascal), + method.operation_id + ); + format!( + "Builder for [`{}`]\n\n[`{}`]: super::{}", + ty, ty, ty, + ) + } + (TagStyle::Separate, _, _) => { + format!( + "Builder for `{}` operation\n\nSee {}\n\n{}", + method.operation_id, + method + .tags + .iter() + .map(|tag| { + format!( + "[`Client{}Ext::{}`]", + sanitize(tag, Case::Pascal), + method.operation_id, + ) + }) + .collect::>() + .join(", "), + method + .tags + .iter() + .map(|tag| { + let ty = format!( + "Client{}Ext::{}", + sanitize(tag, Case::Pascal), + method.operation_id, + ); + format!("[`{}`]: super::{}", ty, ty) + }) + .collect::>() + .join("\n"), + ) + } + }; + + let ret = quote! { + #[doc = #struct_doc] + #maybe_clone + pub struct #struct_ident<'a> { + client: &'a super::Client, + #( #properties ),* + } + + impl<'a> #struct_ident<'a> { + #new_impl + #( #property_impls )* + #send_impl + #stream_impl + } + }; + Ok(ret) + } + + fn builder_helper(&self, method: &OperationMethod) -> BuilderImpl { + let operation_id = format_ident!("{}", method.operation_id); + let struct_name = sanitize(&method.operation_id, Case::Pascal); + let struct_ident = format_ident!("{}", struct_name); + + let params = method + .params + .iter() + .map(|param| format!("\n .{}({})", param.name, param.name)) + .collect::>() + .join(""); + + let eg = format!( + "\ + let response = client.{}(){} + .send() + .await;", + method.operation_id, params, + ); + + // Note that it would be nice to have a non-ignored example that could + // be validated by doc tests, but in order to use the Client we need + // to import it, and in order to import it we need to know the name of + // the containing crate... which we can't from this context. + let doc = + format!("{}\n```ignore\n{}\n```", make_doc_comment(method), eg); + + let sig = quote! { + fn #operation_id(&self) -> builder:: #struct_ident + }; + + let body = quote! { + builder:: #struct_ident ::new(self) + }; + BuilderImpl { doc, sig, body } + } + + pub(crate) fn builder_tags( + &self, + methods: &[OperationMethod], + ) -> TokenStream { + let mut base = Vec::new(); + let mut ext = BTreeMap::new(); + + methods.iter().for_each(|method| { + let BuilderImpl { doc, sig, body } = self.builder_helper(method); + + if method.tags.is_empty() { + let impl_body = quote! { + #[doc = #doc] + pub #sig { + #body + } + }; + base.push(impl_body); + } else { + let trait_sig = quote! { + #[doc = #doc] + #sig; + }; + + let impl_body = quote! { + #sig { + #body + } + }; + method.tags.iter().for_each(|tag| { + ext.entry(tag.clone()) + .or_insert_with(Vec::new) + .push((trait_sig.clone(), impl_body.clone())); + }); + } + }); + + let base_impl = (!base.is_empty()).then(|| { + quote! { + impl Client { + #(#base)* + } + } + }); + + let ext_impl = ext.into_iter().map(|(tag, trait_methods)| { + let tr = format_ident!("Client{}Ext", sanitize(&tag, Case::Pascal)); + let (trait_methods, trait_impls): ( + Vec, + Vec, + ) = trait_methods.into_iter().unzip(); + quote! { + pub trait #tr { + #(#trait_methods)* + } + + impl #tr for Client { + #(#trait_impls)* + } + } + }); + + quote! { + #base_impl + + #(#ext_impl)* + } + } + + pub(crate) fn builder_impl(&self, method: &OperationMethod) -> TokenStream { + let BuilderImpl { doc, sig, body } = self.builder_helper(method); + + let impl_body = quote! { + #[doc = #doc] + pub #sig { + #body + } + }; + + impl_body + } } fn make_doc_comment(method: &OperationMethod) -> String { diff --git a/progenitor-impl/src/template.rs b/progenitor-impl/src/template.rs index 7dd9180..db0e5cc 100644 --- a/progenitor-impl/src/template.rs +++ b/progenitor-impl/src/template.rs @@ -19,7 +19,11 @@ pub struct PathTemplate { } impl PathTemplate { - pub fn compile(&self, rename: HashMap<&String, &String>) -> TokenStream { + pub fn compile( + &self, + rename: HashMap<&String, &String>, + client: TokenStream, + ) -> TokenStream { let mut fmt = String::new(); fmt.push_str("{}"); for c in self.components.iter() { @@ -39,7 +43,7 @@ impl PathTemplate { .expect(&format!("missing path name mapping {}", n)), ); Some(quote! { - progenitor_client::encode_path(&#param.to_string()) + encode_path(&#param.to_string()) }) } else { None @@ -47,7 +51,7 @@ impl PathTemplate { }); quote! { - let url = format!(#fmt, self.baseurl, #(#components,)*); + let url = format!(#fmt, #client.baseurl, #(#components,)*); } } @@ -233,11 +237,11 @@ mod test { let number = "number".to_string(); rename.insert(&number, &number); let t = parse("/measure/{number}").unwrap(); - let out = t.compile(rename); + let out = t.compile(rename, quote::quote! { self }); let want = quote::quote! { let url = format!("{}/measure/{}", self.baseurl, - progenitor_client::encode_path(&number.to_string()), + encode_path(&number.to_string()), ); }; assert_eq!(want.to_string(), out.to_string()); diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out new file mode 100644 index 0000000..6d8d4e6 --- /dev/null +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -0,0 +1,1186 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Task { + pub id: String, + pub name: String, + pub output_rules: Vec, + pub script: String, + pub state: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskEvent { + pub payload: String, + pub seq: u32, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskOutput { + pub id: String, + pub path: String, + pub size: u64, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskSubmit { + pub name: String, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub output_rules: Vec, + pub script: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskSubmitResult { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UploadedChunk { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserCreate { + pub name: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserCreateResult { + pub id: String, + pub name: String, + pub token: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WhoamiResult { + pub id: String, + pub name: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Worker { + pub deleted: bool, + pub id: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub instance_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lastping: Option>, + pub recycle: bool, + pub tasks: Vec, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerAddOutput { + pub chunks: Vec, + pub path: String, + pub size: i64, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerAppendTask { + pub payload: String, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerBootstrap { + pub bootstrap: String, + pub token: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerBootstrapResult { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerPingResult { + pub poweroff: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerPingTask { + pub id: String, + pub output_rules: Vec, + pub script: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerTask { + pub id: String, + pub name: String, + pub owner: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkersResult { + pub workers: Vec, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.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 `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) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_get`] + /// + ///[`Client::task_get`]: super::Client::task_get + #[derive(Clone)] + pub struct TaskGet<'a> { + client: &'a super::Client, + task: Option, + } + + impl<'a> TaskGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, task: None } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/task/{}", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::tasks_get`] + /// + ///[`Client::tasks_get`]: super::Client::tasks_get + #[derive(Clone)] + pub struct TasksGet<'a> { + client: &'a super::Client, + } + + impl<'a> TasksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_submit`] + /// + ///[`Client::task_submit`]: super::Client::task_submit + #[derive(Clone)] + pub struct TaskSubmit<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> TaskSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::TaskSubmit) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/tasks` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskEventsGet<'a> { + client: &'a super::Client, + task: Option, + minseq: Option, + } + + impl<'a> TaskEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + minseq: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn minseq(mut self, value: u32) -> Self { + self.minseq = Some(value); + 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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/events", + client.baseurl, + encode_path(&task.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &minseq { + query.push(("minseq", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskOutputsGet<'a> { + client: &'a super::Client, + task: Option, + } + + impl<'a> TaskOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, task: None } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/outputs", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskOutputDownload<'a> { + client: &'a super::Client, + task: Option, + output: Option, + } + + impl<'a> TaskOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + output: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn output(mut self, value: S) -> Self { + self.output = Some(value.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, output) = match (task, output) { + (Some(task), Some(output)) => (task, output), + (task, output) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if output.is_none() { + missing.push(stringify!(output)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/outputs/{}", + client.baseurl, + encode_path(&task.to_string()), + encode_path(&output.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::user_create`] + /// + ///[`Client::user_create`]: super::Client::user_create + #[derive(Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::UserCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/users` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/users", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami`] + /// + ///[`Client::whoami`]: super::Client::whoami + #[derive(Clone)] + pub struct Whoami<'a> { + client: &'a super::Client, + } + + impl<'a> Whoami<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_bootstrap`] + /// + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + #[derive(Clone)] + pub struct WorkerBootstrap<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> WorkerBootstrap<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::WorkerBootstrap) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_ping`] + /// + ///[`Client::worker_ping`]: super::Client::worker_ping + #[derive(Clone)] + pub struct WorkerPing<'a> { + client: &'a super::Client, + } + + impl<'a> WorkerPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskAppend<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerAppendTask) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/append", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 + pub struct WorkerTaskUploadChunk<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body>(mut self, value: B) -> Self { + self.body = Some(value.into()); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/chunk", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).body(body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskComplete<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskComplete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerCompleteTask) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/complete", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskAddOutput<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskAddOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerAddOutput) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/output", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_list`] + /// + ///[`Client::workers_list`]: super::Client::workers_list + #[derive(Clone)] + pub struct WorkersList<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out new file mode 100644 index 0000000..6d8d4e6 --- /dev/null +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -0,0 +1,1186 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Task { + pub id: String, + pub name: String, + pub output_rules: Vec, + pub script: String, + pub state: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskEvent { + pub payload: String, + pub seq: u32, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskOutput { + pub id: String, + pub path: String, + pub size: u64, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskSubmit { + pub name: String, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub output_rules: Vec, + pub script: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TaskSubmitResult { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UploadedChunk { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserCreate { + pub name: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserCreateResult { + pub id: String, + pub name: String, + pub token: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WhoamiResult { + pub id: String, + pub name: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Worker { + pub deleted: bool, + pub id: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub instance_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub lastping: Option>, + pub recycle: bool, + pub tasks: Vec, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerAddOutput { + pub chunks: Vec, + pub path: String, + pub size: i64, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerAppendTask { + pub payload: String, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerBootstrap { + pub bootstrap: String, + pub token: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerBootstrapResult { + pub id: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerCompleteTask { + pub failed: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerPingResult { + pub poweroff: bool, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub task: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerPingTask { + pub id: String, + pub output_rules: Vec, + pub script: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkerTask { + pub id: String, + pub name: String, + pub owner: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct WorkersResult { + pub workers: Vec, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.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 `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) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`Client::control_hold`] + /// + ///[`Client::control_hold`]: super::Client::control_hold + #[derive(Clone)] + pub struct ControlHold<'a> { + client: &'a super::Client, + } + + impl<'a> ControlHold<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::control_resume`] + /// + ///[`Client::control_resume`]: super::Client::control_resume + #[derive(Clone)] + pub struct ControlResume<'a> { + client: &'a super::Client, + } + + impl<'a> ControlResume<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_get`] + /// + ///[`Client::task_get`]: super::Client::task_get + #[derive(Clone)] + pub struct TaskGet<'a> { + client: &'a super::Client, + task: Option, + } + + impl<'a> TaskGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, task: None } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/task/{}", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::tasks_get`] + /// + ///[`Client::tasks_get`]: super::Client::tasks_get + #[derive(Clone)] + pub struct TasksGet<'a> { + client: &'a super::Client, + } + + impl<'a> TasksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::task_submit`] + /// + ///[`Client::task_submit`]: super::Client::task_submit + #[derive(Clone)] + pub struct TaskSubmit<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> TaskSubmit<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::TaskSubmit) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/tasks` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/tasks", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskEventsGet<'a> { + client: &'a super::Client, + task: Option, + minseq: Option, + } + + impl<'a> TaskEventsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + minseq: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn minseq(mut self, value: u32) -> Self { + self.minseq = Some(value); + 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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/events", + client.baseurl, + encode_path(&task.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &minseq { + query.push(("minseq", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskOutputsGet<'a> { + client: &'a super::Client, + task: Option, + } + + impl<'a> TaskOutputsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, task: None } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.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,) = match (task,) { + (Some(task),) => (task,), + (task,) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/outputs", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct TaskOutputDownload<'a> { + client: &'a super::Client, + task: Option, + output: Option, + } + + impl<'a> TaskOutputDownload<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + output: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn output(mut self, value: S) -> Self { + self.output = Some(value.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, output) = match (task, output) { + (Some(task), Some(output)) => (task, output), + (task, output) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if output.is_none() { + missing.push(stringify!(output)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/tasks/{}/outputs/{}", + client.baseurl, + encode_path(&task.to_string()), + encode_path(&output.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::user_create`] + /// + ///[`Client::user_create`]: super::Client::user_create + #[derive(Clone)] + pub struct UserCreate<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> UserCreate<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::UserCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/users` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/users", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::whoami`] + /// + ///[`Client::whoami`]: super::Client::whoami + #[derive(Clone)] + pub struct Whoami<'a> { + client: &'a super::Client, + } + + impl<'a> Whoami<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_bootstrap`] + /// + ///[`Client::worker_bootstrap`]: super::Client::worker_bootstrap + #[derive(Clone)] + pub struct WorkerBootstrap<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> WorkerBootstrap<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::WorkerBootstrap) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/v1/worker/bootstrap` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/v1/worker/bootstrap", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::worker_ping`] + /// + ///[`Client::worker_ping`]: super::Client::worker_ping + #[derive(Clone)] + pub struct WorkerPing<'a> { + client: &'a super::Client, + } + + impl<'a> WorkerPing<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskAppend<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskAppend<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerAppendTask) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/append", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 + pub struct WorkerTaskUploadChunk<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskUploadChunk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body>(mut self, value: B) -> Self { + self.body = Some(value.into()); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/chunk", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).body(body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskComplete<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskComplete<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerCompleteTask) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/complete", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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(Clone)] + pub struct WorkerTaskAddOutput<'a> { + client: &'a super::Client, + task: Option, + body: Option, + } + + impl<'a> WorkerTaskAddOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + task: None, + body: None, + } + } + + pub fn task(mut self, value: S) -> Self { + self.task = Some(value.to_string()); + self + } + + pub fn body(mut self, value: types::WorkerAddOutput) -> Self { + self.body = Some(value); + 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, body) = match (task, body) { + (Some(task), Some(body)) => (task, body), + (task, body) => { + let mut missing = Vec::new(); + if task.is_none() { + missing.push(stringify!(task)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/v1/worker/task/{}/output", + client.baseurl, + encode_path(&task.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_list`] + /// + ///[`Client::workers_list`]: super::Client::workers_list + #[derive(Clone)] + pub struct WorkersList<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::workers_recycle`] + /// + ///[`Client::workers_recycle`]: super::Client::workers_recycle + #[derive(Clone)] + pub struct WorkersRecycle<'a> { + client: &'a super::Client, + } + + impl<'a> WorkersRecycle<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/buildomat.out b/progenitor-impl/tests/output/buildomat-positional.out similarity index 86% rename from progenitor-impl/tests/output/buildomat.out rename to progenitor-impl/tests/output/buildomat-positional.out index f6403a9..badf83b 100644 --- a/progenitor-impl/tests/output/buildomat.out +++ b/progenitor-impl/tests/output/buildomat-positional.out @@ -1,3 +1,5 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; @@ -132,8 +134,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -161,8 +163,10 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "Sends a `POST` request to `/v1/control/hold`"] +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 = self.client.post(url).build()?; @@ -174,7 +178,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/control/resume`"] + ///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 = self.client.post(url).build()?; @@ -186,7 +190,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/task/{task}`"] + ///Sends a `GET` request to `/v1/task/{task}` pub async fn task_get<'a>( &'a self, task: &'a str, @@ -194,7 +198,7 @@ impl Client { let url = format!( "{}/v1/task/{}", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -205,7 +209,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/tasks`"] + ///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 = self.client.get(url).build()?; @@ -217,13 +221,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/tasks`"] + ///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 = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -232,7 +236,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/tasks/{task}/events`"] + ///Sends a `GET` request to `/v1/tasks/{task}/events` pub async fn task_events_get<'a>( &'a self, task: &'a str, @@ -241,7 +245,7 @@ impl Client { let url = format!( "{}/v1/tasks/{}/events", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); let mut query = Vec::new(); if let Some(v) = &minseq { @@ -257,7 +261,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/tasks/{task}/outputs`"] + ///Sends a `GET` request to `/v1/tasks/{task}/outputs` pub async fn task_outputs_get<'a>( &'a self, task: &'a str, @@ -265,7 +269,7 @@ impl Client { let url = format!( "{}/v1/tasks/{}/outputs", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -276,7 +280,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}`"] + ///Sends a `GET` request to `/v1/tasks/{task}/outputs/{output}` pub async fn task_output_download<'a>( &'a self, task: &'a str, @@ -285,8 +289,8 @@ impl Client { let url = format!( "{}/v1/tasks/{}/outputs/{}", self.baseurl, - progenitor_client::encode_path(&task.to_string()), - progenitor_client::encode_path(&output.to_string()), + encode_path(&task.to_string()), + encode_path(&output.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -297,13 +301,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/users`"] + ///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 = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -312,7 +316,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/whoami`"] + ///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 = self.client.get(url).build()?; @@ -324,13 +328,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/worker/bootstrap`"] + ///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 = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -339,7 +343,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/worker/ping`"] + ///Sends a `GET` request to `/v1/worker/ping` pub async fn worker_ping<'a>( &'a self, ) -> Result, Error<()>> { @@ -353,7 +357,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/worker/task/{task}/append`"] + ///Sends a `POST` request to `/v1/worker/task/{task}/append` pub async fn worker_task_append<'a>( &'a self, task: &'a str, @@ -362,9 +366,9 @@ impl Client { let url = format!( "{}/v1/worker/task/{}/append", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -373,7 +377,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/worker/task/{task}/chunk`"] + ///Sends a `POST` request to `/v1/worker/task/{task}/chunk` pub async fn worker_task_upload_chunk<'a, B: Into>( &'a self, task: &'a str, @@ -382,7 +386,7 @@ impl Client { let url = format!( "{}/v1/worker/task/{}/chunk", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); let request = self.client.post(url).body(body).build()?; let result = self.client.execute(request).await; @@ -393,7 +397,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/worker/task/{task}/complete`"] + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` pub async fn worker_task_complete<'a>( &'a self, task: &'a str, @@ -402,9 +406,9 @@ impl Client { let url = format!( "{}/v1/worker/task/{}/complete", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -413,7 +417,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/worker/task/{task}/output`"] + ///Sends a `POST` request to `/v1/worker/task/{task}/output` pub async fn worker_task_add_output<'a>( &'a self, task: &'a str, @@ -422,9 +426,9 @@ impl Client { let url = format!( "{}/v1/worker/task/{}/output", self.baseurl, - progenitor_client::encode_path(&task.to_string()), + encode_path(&task.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -433,7 +437,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/v1/workers`"] + ///Sends a `GET` request to `/v1/workers` pub async fn workers_list<'a>( &'a self, ) -> Result, Error<()>> { @@ -447,7 +451,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/v1/workers/recycle`"] + ///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 = self.client.post(url).build()?; diff --git a/progenitor-impl/tests/output/keeper-builder-tagged.out b/progenitor-impl/tests/output/keeper-builder-tagged.out new file mode 100644 index 0000000..4719912 --- /dev/null +++ b/progenitor-impl/tests/output/keeper-builder-tagged.out @@ -0,0 +1,418 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct EnrolBody { + pub host: String, + pub key: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalJobsResult { + pub summary: Vec, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OutputRecord { + pub msg: String, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct PingResult { + pub host: String, + pub ok: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportFinishBody { + pub duration_millis: i32, + pub end_time: chrono::DateTime, + pub exit_status: i32, + pub id: ReportId, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportId { + pub host: String, + pub job: String, + pub pid: u64, + pub time: chrono::DateTime, + pub uuid: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportOutputBody { + pub id: ReportId, + pub record: OutputRecord, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportResult { + pub existed_already: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportStartBody { + pub id: ReportId, + pub script: String, + pub start_time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportSummary { + pub age_seconds: i32, + pub duration_seconds: i32, + pub host: String, + pub job: String, + pub status: i32, + pub when: chrono::DateTime, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.client + } +} + +impl Client { + ///Sends a `POST` request to `/enrol` + ///```ignore + /// let response = client.enrol() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn enrol(&self) -> builder::Enrol { + builder::Enrol::new(self) + } + + ///Sends a `GET` request to `/global/jobs` + ///```ignore + /// let response = client.global_jobs() + /// .send() + /// .await; + /// ``` + pub fn global_jobs(&self) -> builder::GlobalJobs { + builder::GlobalJobs::new(self) + } + + ///Sends a `GET` request to `/ping` + ///```ignore + /// let response = client.ping() + /// .send() + /// .await; + /// ``` + pub fn ping(&self) -> builder::Ping { + builder::Ping::new(self) + } + + ///Sends a `POST` request to `/report/finish` + ///```ignore + /// let response = client.report_finish() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_finish(&self) -> builder::ReportFinish { + builder::ReportFinish::new(self) + } + + ///Sends a `POST` request to `/report/output` + ///```ignore + /// let response = client.report_output() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_output(&self) -> builder::ReportOutput { + builder::ReportOutput::new(self) + } + + ///Sends a `POST` request to `/report/start` + ///```ignore + /// let response = client.report_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_start(&self) -> builder::ReportStart { + builder::ReportStart::new(self) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`Client::enrol`] + /// + ///[`Client::enrol`]: super::Client::enrol + #[derive(Clone)] + pub struct Enrol<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> Enrol<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::EnrolBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/enrol` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/enrol", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::global_jobs`] + /// + ///[`Client::global_jobs`]: super::Client::global_jobs + #[derive(Clone)] + pub struct GlobalJobs<'a> { + client: &'a super::Client, + } + + impl<'a> GlobalJobs<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/global/jobs` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/global/jobs", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ping`] + /// + ///[`Client::ping`]: super::Client::ping + #[derive(Clone)] + pub struct Ping<'a> { + client: &'a super::Client, + } + + impl<'a> Ping<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/ping", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_finish`] + /// + ///[`Client::report_finish`]: super::Client::report_finish + #[derive(Clone)] + pub struct ReportFinish<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportFinish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportFinishBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/finish` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/finish", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_output`] + /// + ///[`Client::report_output`]: super::Client::report_output + #[derive(Clone)] + pub struct ReportOutput<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportOutputBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/output", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_start`] + /// + ///[`Client::report_start`]: super::Client::report_start + #[derive(Clone)] + pub struct ReportStart<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportStartBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/start` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/start", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/keeper-builder.out b/progenitor-impl/tests/output/keeper-builder.out new file mode 100644 index 0000000..4719912 --- /dev/null +++ b/progenitor-impl/tests/output/keeper-builder.out @@ -0,0 +1,418 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct EnrolBody { + pub host: String, + pub key: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalJobsResult { + pub summary: Vec, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OutputRecord { + pub msg: String, + pub stream: String, + pub time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct PingResult { + pub host: String, + pub ok: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportFinishBody { + pub duration_millis: i32, + pub end_time: chrono::DateTime, + pub exit_status: i32, + pub id: ReportId, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportId { + pub host: String, + pub job: String, + pub pid: u64, + pub time: chrono::DateTime, + pub uuid: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportOutputBody { + pub id: ReportId, + pub record: OutputRecord, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportResult { + pub existed_already: bool, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportStartBody { + pub id: ReportId, + pub script: String, + pub start_time: chrono::DateTime, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ReportSummary { + pub age_seconds: i32, + pub duration_seconds: i32, + pub host: String, + pub job: String, + pub status: i32, + pub when: chrono::DateTime, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.client + } +} + +impl Client { + ///Sends a `POST` request to `/enrol` + ///```ignore + /// let response = client.enrol() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn enrol(&self) -> builder::Enrol { + builder::Enrol::new(self) + } + + ///Sends a `GET` request to `/global/jobs` + ///```ignore + /// let response = client.global_jobs() + /// .send() + /// .await; + /// ``` + pub fn global_jobs(&self) -> builder::GlobalJobs { + builder::GlobalJobs::new(self) + } + + ///Sends a `GET` request to `/ping` + ///```ignore + /// let response = client.ping() + /// .send() + /// .await; + /// ``` + pub fn ping(&self) -> builder::Ping { + builder::Ping::new(self) + } + + ///Sends a `POST` request to `/report/finish` + ///```ignore + /// let response = client.report_finish() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_finish(&self) -> builder::ReportFinish { + builder::ReportFinish::new(self) + } + + ///Sends a `POST` request to `/report/output` + ///```ignore + /// let response = client.report_output() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_output(&self) -> builder::ReportOutput { + builder::ReportOutput::new(self) + } + + ///Sends a `POST` request to `/report/start` + ///```ignore + /// let response = client.report_start() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn report_start(&self) -> builder::ReportStart { + builder::ReportStart::new(self) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`Client::enrol`] + /// + ///[`Client::enrol`]: super::Client::enrol + #[derive(Clone)] + pub struct Enrol<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> Enrol<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::EnrolBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/enrol` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/enrol", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => Ok(ResponseValue::empty(response)), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::global_jobs`] + /// + ///[`Client::global_jobs`]: super::Client::global_jobs + #[derive(Clone)] + pub struct GlobalJobs<'a> { + client: &'a super::Client, + } + + impl<'a> GlobalJobs<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/global/jobs` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/global/jobs", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::ping`] + /// + ///[`Client::ping`]: super::Client::ping + #[derive(Clone)] + pub struct Ping<'a> { + client: &'a super::Client, + } + + impl<'a> Ping<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `GET` request to `/ping` + pub async fn send(self) -> Result, Error<()>> { + let Self { client } = self; + let url = format!("{}/ping", client.baseurl,); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_finish`] + /// + ///[`Client::report_finish`]: super::Client::report_finish + #[derive(Clone)] + pub struct ReportFinish<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportFinish<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportFinishBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/finish` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/finish", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_output`] + /// + ///[`Client::report_output`]: super::Client::report_output + #[derive(Clone)] + pub struct ReportOutput<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportOutput<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportOutputBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/output` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/output", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`Client::report_start`] + /// + ///[`Client::report_start`]: super::Client::report_start + #[derive(Clone)] + pub struct ReportStart<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ReportStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ReportStartBody) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/report/start` + pub async fn send(self) -> Result, Error<()>> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/report/start", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 201u16 => ResponseValue::from_response(response).await, + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/keeper.out b/progenitor-impl/tests/output/keeper-positional.out similarity index 88% rename from progenitor-impl/tests/output/keeper.out rename to progenitor-impl/tests/output/keeper-positional.out index 35f9879..9fb0fac 100644 --- a/progenitor-impl/tests/output/keeper.out +++ b/progenitor-impl/tests/output/keeper-positional.out @@ -1,3 +1,5 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; @@ -73,8 +75,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -102,14 +104,16 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "Sends a `POST` request to `/enrol`"] +impl Client { + ///Sends a `POST` request to `/enrol` pub async fn enrol<'a>( &'a self, body: &'a types::EnrolBody, ) -> Result, Error<()>> { let url = format!("{}/enrol", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -118,7 +122,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/global/jobs`"] + ///Sends a `GET` request to `/global/jobs` pub async fn global_jobs<'a>( &'a self, ) -> Result, Error<()>> { @@ -132,7 +136,7 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/ping`"] + ///Sends a `GET` request to `/ping` pub async fn ping<'a>(&'a self) -> Result, Error<()>> { let url = format!("{}/ping", self.baseurl,); let request = self.client.get(url).build()?; @@ -144,13 +148,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/report/finish`"] + ///Sends a `POST` request to `/report/finish` pub async fn report_finish<'a>( &'a self, body: &'a types::ReportFinishBody, ) -> Result, Error<()>> { let url = format!("{}/report/finish", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -159,13 +163,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/report/output`"] + ///Sends a `POST` request to `/report/output` pub async fn report_output<'a>( &'a self, body: &'a types::ReportOutputBody, ) -> Result, Error<()>> { let url = format!("{}/report/output", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -174,13 +178,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/report/start`"] + ///Sends a `POST` request to `/report/start` pub async fn report_start<'a>( &'a self, body: &'a types::ReportStartBody, ) -> Result, Error<()>> { let url = format!("{}/report/start", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { diff --git a/progenitor-impl/tests/output/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out new file mode 100644 index 0000000..0305dec --- /dev/null +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -0,0 +1,13071 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct BlockSize(i64); + impl std::ops::Deref for BlockSize { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl std::convert::TryFrom for BlockSize { + type Error = &'static str; + fn try_from(value: i64) -> Result { + if ![512_i64, 2048_i64, 4096_i64].contains(&value) { + Err("invalid value") + } else { + Ok(Self(value)) + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ByteCount(pub u64); + impl std::ops::Deref for ByteCount { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///The type of an individual datum of a metric. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + 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 ToString for DatumType { + fn to_string(&self) -> String { + match *self { + DatumType::Bool => "bool".to_string(), + DatumType::I64 => "i64".to_string(), + DatumType::F64 => "f64".to_string(), + DatumType::String => "string".to_string(), + DatumType::Bytes => "bytes".to_string(), + DatumType::CumulativeI64 => "cumulative_i64".to_string(), + DatumType::CumulativeF64 => "cumulative_f64".to_string(), + DatumType::HistogramI64 => "histogram_i64".to_string(), + DatumType::HistogramF64 => "histogram_f64".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Digest { + #[serde(rename = "type")] + pub type_: DigestType, + pub value: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum DigestType { + #[serde(rename = "sha256")] + Sha256, + } + + impl ToString for DigestType { + fn to_string(&self) -> String { + match *self { + DigestType::Sha256 => "sha256".to_string(), + } + } + } + + ///Client view of an [`Disk`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Disk { + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + pub device_path: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub image_id: Option, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: uuid::Uuid, + pub size: ByteCount, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub snapshot_id: Option, + pub state: DiskState, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskCreate { + pub description: String, + ///initial source for this disk + pub disk_source: DiskSource, + pub name: Name, + ///total size of the Disk in bytes + pub size: ByteCount, + } + + ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be + /// attached or detached to an instance + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskIdentifier { + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Different sources for a disk + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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 }, + } + + ///State of a Disk (primarily: attached or not) + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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, + } + + ///Error information from a response. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Error { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error_code: Option, + pub message: String, + pub request_id: String, + } + + ///The name and type information for a field of a timeseries schema. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FieldSchema { + pub name: String, + pub source: FieldSource, + pub ty: FieldType, + } + + ///The source from which a field is derived, the target or metric. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum FieldSource { + #[serde(rename = "target")] + Target, + #[serde(rename = "metric")] + Metric, + } + + impl ToString for FieldSource { + fn to_string(&self) -> String { + match *self { + FieldSource::Target => "target".to_string(), + FieldSource::Metric => "metric".to_string(), + } + } + } + + ///The `FieldType` identifies the data type of a target or metric field. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + 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 ToString for FieldType { + fn to_string(&self) -> String { + match *self { + FieldType::String => "string".to_string(), + FieldType::I64 => "i64".to_string(), + FieldType::IpAddr => "ip_addr".to_string(), + FieldType::Uuid => "uuid".to_string(), + FieldType::Bool => "bool".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum FleetRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for FleetRoles { + fn to_string(&self) -> String { + match *self { + FleetRoles::Admin => "admin".to_string(), + FleetRoles::Collaborator => "collaborator".to_string(), + FleetRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FleetRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FleetRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: FleetRoles, + } + + ///Client view of global Images + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalImage { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "Option::is_none")] + pub digest: Option, + ///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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + ///Version of this, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalImageResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum IdSortMode { + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ToString for IdSortMode { + fn to_string(&self) -> String { + match *self { + IdSortMode::IdAscending => "id_ascending".to_string(), + } + } + } + + ///Describes what kind of identity is described by an id + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum IdentityType { + #[serde(rename = "silo_user")] + SiloUser, + } + + impl ToString for IdentityType { + fn to_string(&self) -> String { + match *self { + IdentityType::SiloUser => "silo_user".to_string(), + } + } + } + + ///Client view of project Images + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Image { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "Option::is_none")] + pub digest: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + ///Version of this, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + } + + ///Create-time parameters for an + /// [`Image`](omicron_common::api::external::Image) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: String, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ImageResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///The source of the underlying image. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "src")] + pub enum ImageSource { + #[serde(rename = "url")] + Url(String), + #[serde(rename = "snapshot")] + Snapshot(uuid::Uuid), + } + + ///Client view of an [`Instance`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Instance { + ///human-readable free-form text about a resource + pub description: String, + ///RFC1035-compliant hostname for the Instance. + pub hostname: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub time_run_state_updated: chrono::DateTime, + } + + ///The number of CPUs in an Instance + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceCpuCount(pub u16); + impl std::ops::Deref for InstanceCpuCount { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceCreate { + pub description: String, + ///The disks to be created or attached for this instance. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub disks: Vec, + pub hostname: String, + pub memory: ByteCount, + pub name: Name, + pub ncpus: InstanceCpuCount, + ///The network interfaces to be created for this instance. + #[serde(default = "instance_create_network_interfaces")] + pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///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: String, + } + + fn instance_create_network_interfaces() -> InstanceNetworkInterfaceAttachment { + InstanceNetworkInterfaceAttachment::Default + } + + ///Describe the instance's disks at creation time + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type")] + pub enum InstanceDiskAttachment { + ///During instance creation, create and attach disks + #[serde(rename = "create")] + Create { + description: 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, + }, + } + + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceMigrate { + pub dst_sled_uuid: uuid::Uuid, + } + + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "params")] + pub enum InstanceNetworkInterfaceAttachment { + ///Create one or more `NetworkInterface`s for the `Instance` + #[serde(rename = "create")] + Create(Vec), + #[serde(rename = "default")] + Default, + #[serde(rename = "none")] + None, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///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 + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum InstanceState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "starting")] + Starting, + #[serde(rename = "running")] + Running, + #[serde(rename = "stopping")] + Stopping, + #[serde(rename = "stopped")] + Stopped, + #[serde(rename = "rebooting")] + Rebooting, + #[serde(rename = "migrating")] + Migrating, + #[serde(rename = "repairing")] + Repairing, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ToString for InstanceState { + fn to_string(&self) -> String { + match *self { + InstanceState::Creating => "creating".to_string(), + InstanceState::Starting => "starting".to_string(), + InstanceState::Running => "running".to_string(), + InstanceState::Stopping => "stopping".to_string(), + InstanceState::Stopped => "stopped".to_string(), + InstanceState::Rebooting => "rebooting".to_string(), + InstanceState::Migrating => "migrating".to_string(), + InstanceState::Repairing => "repairing".to_string(), + InstanceState::Failed => "failed".to_string(), + InstanceState::Destroyed => "destroyed".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(untagged)] + pub enum IpNet { + V4(Ipv4Net), + V6(Ipv6Net), + } + + ///An IPv4 subnet, including prefix and subnet mask + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Ipv4Net(pub String); + impl std::ops::Deref for Ipv4Net { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///An IPv6 subnet, including prefix and subnet mask + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Ipv6Net(pub String); + impl std::ops::Deref for Ipv6Net { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct L4PortRange(pub String); + impl std::ops::Deref for L4PortRange { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct LoginParams { + pub username: String, + } + + ///A Media Access Control address, in EUI-48 format + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct MacAddr(pub String); + impl std::ops::Deref for MacAddr { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///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 '-'. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Name(pub String); + impl std::ops::Deref for Name { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///Supported set of sort modes for scanning by name or id + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum NameOrIdSortMode { + #[serde(rename = "name_ascending")] + NameAscending, + #[serde(rename = "name_descending")] + NameDescending, + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ToString for NameOrIdSortMode { + fn to_string(&self) -> String { + match *self { + NameOrIdSortMode::NameAscending => "name_ascending".to_string(), + NameOrIdSortMode::NameDescending => "name_descending".to_string(), + NameOrIdSortMode::IdAscending => "id_ascending".to_string(), + } + } + } + + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum NameSortMode { + #[serde(rename = "name_ascending")] + NameAscending, + } + + impl ToString for NameSortMode { + fn to_string(&self) -> String { + match *self { + NameSortMode::NameAscending => "name_ascending".to_string(), + } + } + } + + ///A `NetworkInterface` represents a virtual network interface device. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterface { + ///human-readable free-form text about a resource + pub description: 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: String, + ///The MAC address assigned to this interface. + pub mac: MacAddr, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///The subnet to which the interface belongs. + pub subnet_id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the interface belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterfaceCreate { + pub description: String, + ///The IP address for the interface. One will be auto-assigned if not + /// provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ip: Option, + 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, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterfaceResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of an [`Organization`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Organization { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationCreate { + pub description: String, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum OrganizationRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + } + + impl ToString for OrganizationRoles { + fn to_string(&self) -> String { + match *self { + OrganizationRoles::Admin => "admin".to_string(), + OrganizationRoles::Collaborator => "collaborator".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: OrganizationRoles, + } + + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Client view of a [`Project`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Project { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectCreate { + pub description: String, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum ProjectRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for ProjectRoles { + fn to_string(&self) -> String { + match *self { + ProjectRoles::Admin => "admin".to_string(), + ProjectRoles::Collaborator => "collaborator".to_string(), + ProjectRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: ProjectRoles, + } + + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Client view of an [`Rack`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Rack { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RackResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`Role`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Role { + pub description: String, + pub name: RoleName, + } + + ///Role names consist of two string components separated by dot ("."). + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RoleName(pub String); + impl std::ops::Deref for RoleName { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RoleResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "value")] + pub enum RouteDestination { + ///Route applies to traffic destined for a specific IP address + #[serde(rename = "ip")] + Ip(String), + ///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), + } + + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "value")] + pub enum RouteTarget { + ///Forward traffic to a particular IP address. + #[serde(rename = "ip")] + Ip(String), + ///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), + } + + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRoute { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC Router to which the route belongs. + pub vpc_router_id: uuid::Uuid, + } + + ///Create-time parameters for a [`RouterRoute`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteCreateParams { + pub description: String, + pub destination: RouteDestination, + pub name: Name, + pub target: RouteTarget, + } + + ///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 + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum RouterRouteKind { + #[serde(rename = "default")] + Default, + #[serde(rename = "vpc_subnet")] + VpcSubnet, + #[serde(rename = "vpc_peering")] + VpcPeering, + #[serde(rename = "custom")] + Custom, + } + + impl ToString for RouterRouteKind { + fn to_string(&self) -> String { + match *self { + RouterRouteKind::Default => "default".to_string(), + RouterRouteKind::VpcSubnet => "vpc_subnet".to_string(), + RouterRouteKind::VpcPeering => "vpc_peering".to_string(), + RouterRouteKind::Custom => "custom".to_string(), + } + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a [`RouterRoute`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteUpdateParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + pub destination: RouteDestination, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + pub target: RouteTarget, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Saga { + pub id: uuid::Uuid, + pub state: SagaState, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "error")] + pub enum SagaErrorInfo { + #[serde(rename = "action_failed")] + ActionFailed { source_error: serde_json::Value }, + #[serde(rename = "deserialize_failed")] + DeserializeFailed { message: String }, + #[serde(rename = "injected_error")] + InjectedError, + #[serde(rename = "serialize_failed")] + SerializeFailed { message: String }, + #[serde(rename = "subsaga_create_failed")] + SubsagaCreateFailed { message: String }, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SagaResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "state")] + pub enum SagaState { + #[serde(rename = "running")] + Running, + #[serde(rename = "succeeded")] + Succeeded, + #[serde(rename = "failed")] + Failed { + error_info: SagaErrorInfo, + error_node_name: String, + }, + } + + ///Client view of currently authed user. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SessionUser { + pub id: uuid::Uuid, + } + + ///Client view of a ['Silo'] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Silo { + ///human-readable free-form text about a resource + pub description: 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, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloCreate { + pub description: String, + pub discoverable: bool, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum SiloRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for SiloRoles { + fn to_string(&self) -> String { + match *self { + SiloRoles::Admin => "admin".to_string(), + SiloRoles::Collaborator => "collaborator".to_string(), + SiloRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: SiloRoles, + } + + ///Client view of an [`Sled`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Sled { + ///human-readable free-form text about a resource + pub description: 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_address: String, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SledResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a Snapshot + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Snapshot { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Snapshot`](omicron_common::api::external::Snapshot) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SnapshotCreate { + pub description: String, + ///The name of the disk to be snapshotted + pub disk: Name, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SnapshotResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`SshKey`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKey { + ///human-readable free-form text about a resource + pub description: 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: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKeyCreate { + pub description: String, + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: String, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKeyResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesName(pub String); + impl std::ops::Deref for TimeseriesName { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesSchema { + pub created: chrono::DateTime, + pub datum_type: DatumType, + pub field_schema: Vec, + pub timeseries_name: TimeseriesName, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesSchemaResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`User`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct User { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`Vpc`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Vpc { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcCreate { + pub description: 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 = "Option::is_none")] + pub ipv6_prefix: Option, + pub name: Name, + } + + ///A single rule in a VPC firewall + #[derive(Serialize, Deserialize, Debug, Clone)] + 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: 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: Vec, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///the VPC to which this rule belongs + pub vpc_id: uuid::Uuid, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleAction { + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + } + + impl ToString for VpcFirewallRuleAction { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleAction::Allow => "allow".to_string(), + VpcFirewallRuleAction::Deny => "deny".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleDirection { + #[serde(rename = "inbound")] + Inbound, + #[serde(rename = "outbound")] + Outbound, + } + + impl ToString for VpcFirewallRuleDirection { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleDirection::Inbound => "inbound".to_string(), + VpcFirewallRuleDirection::Outbound => "outbound".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRuleFilter { + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hosts: Option>, + ///If present, the destination ports this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ports: Option>, + ///If present, the networking protocols this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub protocols: Option>, + } + + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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(String), + ///The rule applies to traffic from/to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + ///The protocols that may be specified in a firewall rule's filter + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleProtocol { + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, + #[serde(rename = "ICMP")] + Icmp, + } + + impl ToString for VpcFirewallRuleProtocol { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleProtocol::Tcp => "TCP".to_string(), + VpcFirewallRuleProtocol::Udp => "UDP".to_string(), + VpcFirewallRuleProtocol::Icmp => "ICMP".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleStatus { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + } + + impl ToString for VpcFirewallRuleStatus { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleStatus::Disabled => "disabled".to_string(), + VpcFirewallRuleStatus::Enabled => "enabled".to_string(), + } + } + } + + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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(String), + ///The rule applies to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + ///A single rule in a VPC firewall + #[derive(Serialize, Deserialize, Debug, Clone)] + 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: 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: Vec, + } + + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRuleUpdateParams { + pub rules: Vec, + } + + ///Collection of a [`Vpc`]'s firewall rules + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRules { + pub rules: Vec, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouter { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the router belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterCreate { + pub description: String, + pub name: Name, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcRouterKind { + #[serde(rename = "system")] + System, + #[serde(rename = "custom")] + Custom, + } + + impl ToString for VpcRouterKind { + fn to_string(&self) -> String { + match *self { + VpcRouterKind::System => "system".to_string(), + VpcRouterKind::Custom => "custom".to_string(), + } + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnet { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the subnet belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetCreate { + pub description: 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 = "Option::is_none")] + pub ipv6_block: Option, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dns_name: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.client + } +} + +pub trait ClientDisksExt { + ///List disks in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_disks_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_disks_get(&self) -> builder::ProjectDisksGet; + ///Create a disk in a project + /// + ///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.project_disks_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_disks_post(&self) -> builder::ProjectDisksPost; + ///Fetch a single disk in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` ```ignore + /// let response = client.project_disks_get_disk() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + fn project_disks_get_disk(&self) -> builder::ProjectDisksGetDisk; + ///Delete a disk from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` ```ignore + /// let response = client.project_disks_delete_disk() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + fn project_disks_delete_disk(&self) -> builder::ProjectDisksDeleteDisk; +} + +impl ClientDisksExt for Client { + fn project_disks_get(&self) -> builder::ProjectDisksGet { + builder::ProjectDisksGet::new(self) + } + + fn project_disks_post(&self) -> builder::ProjectDisksPost { + builder::ProjectDisksPost::new(self) + } + + fn project_disks_get_disk(&self) -> builder::ProjectDisksGetDisk { + builder::ProjectDisksGetDisk::new(self) + } + + fn project_disks_delete_disk(&self) -> builder::ProjectDisksDeleteDisk { + builder::ProjectDisksDeleteDisk::new(self) + } +} + +pub trait ClientFirewallExt { + ///List firewall rules for a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` ```ignore + /// let response = client.vpc_firewall_rules_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn vpc_firewall_rules_get(&self) -> builder::VpcFirewallRulesGet; + ///Replace the firewall rules for a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` ```ignore + /// let response = client.vpc_firewall_rules_put() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_firewall_rules_put(&self) -> builder::VpcFirewallRulesPut; +} + +impl ClientFirewallExt for Client { + fn vpc_firewall_rules_get(&self) -> builder::VpcFirewallRulesGet { + builder::VpcFirewallRulesGet::new(self) + } + + fn vpc_firewall_rules_put(&self) -> builder::VpcFirewallRulesPut { + builder::VpcFirewallRulesPut::new(self) + } +} + +pub trait ClientHiddenExt { + ///Sends a `POST` request to `/login` + ///```ignore + /// let response = client.spoof_login() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn spoof_login(&self) -> builder::SpoofLogin; + ///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; +} + +impl ClientHiddenExt for Client { + fn spoof_login(&self) -> builder::SpoofLogin { + builder::SpoofLogin::new(self) + } + + fn logout(&self) -> builder::Logout { + builder::Logout::new(self) + } + + fn session_me(&self) -> builder::SessionMe { + builder::SessionMe::new(self) + } +} + +pub trait ClientImagesExt { + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_images_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_images_get(&self) -> builder::ProjectImagesGet; + ///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.project_images_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_images_post(&self) -> builder::ProjectImagesPost; + ///Get an image + /// + ///Get the details of a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` ```ignore + /// let response = client.project_images_get_image() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn project_images_get_image(&self) -> builder::ProjectImagesGetImage; + ///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.project_images_delete_image() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn project_images_delete_image(&self) -> builder::ProjectImagesDeleteImage; +} + +impl ClientImagesExt for Client { + fn project_images_get(&self) -> builder::ProjectImagesGet { + builder::ProjectImagesGet::new(self) + } + + fn project_images_post(&self) -> builder::ProjectImagesPost { + builder::ProjectImagesPost::new(self) + } + + fn project_images_get_image(&self) -> builder::ProjectImagesGetImage { + builder::ProjectImagesGetImage::new(self) + } + + fn project_images_delete_image(&self) -> builder::ProjectImagesDeleteImage { + builder::ProjectImagesDeleteImage::new(self) + } +} + +pub trait ClientImagesGlobalExt { + ///List global images + /// + ///Returns a list of all the global images. Global images are returned + /// sorted by creation date, with the most recent images appearing first. + /// + ///Sends a `GET` request to `/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.images_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn images_get(&self) -> builder::ImagesGet; + ///Create a global image + /// + ///Create a new global image. This image can then be used by any user as a + /// base for instances. + /// + ///Sends a `POST` request to `/images` + ///```ignore + /// let response = client.images_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn images_post(&self) -> builder::ImagesPost; + ///Get a global image + /// + ///Returns the details of a specific global image. + /// + ///Sends a `GET` request to `/images/{image_name}` + ///```ignore + /// let response = client.images_get_image() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn images_get_image(&self) -> builder::ImagesGetImage; + ///Delete a global image + /// + ///Permanently delete a global image. This operation cannot be undone. Any + /// instances using the global image will continue to run, however new + /// instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/images/{image_name}` + ///```ignore + /// let response = client.images_delete_image() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + fn images_delete_image(&self) -> builder::ImagesDeleteImage; +} + +impl ClientImagesGlobalExt for Client { + fn images_get(&self) -> builder::ImagesGet { + builder::ImagesGet::new(self) + } + + fn images_post(&self) -> builder::ImagesPost { + builder::ImagesPost::new(self) + } + + fn images_get_image(&self) -> builder::ImagesGetImage { + builder::ImagesGetImage::new(self) + } + + fn images_delete_image(&self) -> builder::ImagesDeleteImage { + builder::ImagesDeleteImage::new(self) + } +} + +pub trait ClientInstancesExt { + ///List instances in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_instances_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_instances_get(&self) -> builder::ProjectInstancesGet; + ///Create an instance in a project + /// + ///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.project_instances_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_instances_post(&self) -> builder::ProjectInstancesPost; + ///Get an instance in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` ```ignore + /// let response = client.project_instances_get_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn project_instances_get_instance(&self) -> builder::ProjectInstancesGetInstance; + ///Delete an instance from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` ```ignore + /// let response = client.project_instances_delete_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn project_instances_delete_instance(&self) -> builder::ProjectInstancesDeleteInstance; + ///List disks attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.instance_disks_get() + /// .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_disks_get(&self) -> builder::InstanceDisksGet; + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` ```ignore + /// let response = client.instance_disks_attach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disks_attach(&self) -> builder::InstanceDisksAttach; + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` ```ignore + /// let response = client.instance_disks_detach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_disks_detach(&self) -> builder::InstanceDisksDetach; + ///Migrate an instance to a different propolis-server, possibly on a + /// different sled + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` ```ignore + /// let response = client.project_instances_migrate_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_instances_migrate_instance(&self) -> builder::ProjectInstancesMigrateInstance; + ///List network interfaces attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.instance_network_interfaces_get() + /// .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_interfaces_get(&self) -> builder::InstanceNetworkInterfacesGet; + ///Create a network interface for an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` ```ignore + /// let response = client.instance_network_interfaces_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn instance_network_interfaces_post(&self) -> builder::InstanceNetworkInterfacesPost; + ///Get an interface attached to an instance + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` ```ignore + /// let response = client.instance_network_interfaces_get_interface() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + fn instance_network_interfaces_get_interface( + &self, + ) -> builder::InstanceNetworkInterfacesGetInterface; + ///Detach a network interface from an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` ```ignore + /// let response = client.instance_network_interfaces_delete_interface() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + fn instance_network_interfaces_delete_interface( + &self, + ) -> builder::InstanceNetworkInterfacesDeleteInterface; + ///Reboot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` ```ignore + /// let response = client.project_instances_instance_reboot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn project_instances_instance_reboot(&self) -> builder::ProjectInstancesInstanceReboot; + ///Boot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` ```ignore + /// let response = client.project_instances_instance_start() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn project_instances_instance_start(&self) -> builder::ProjectInstancesInstanceStart; + ///Halt an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` ```ignore + /// let response = client.project_instances_instance_stop() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + fn project_instances_instance_stop(&self) -> builder::ProjectInstancesInstanceStop; +} + +impl ClientInstancesExt for Client { + fn project_instances_get(&self) -> builder::ProjectInstancesGet { + builder::ProjectInstancesGet::new(self) + } + + fn project_instances_post(&self) -> builder::ProjectInstancesPost { + builder::ProjectInstancesPost::new(self) + } + + fn project_instances_get_instance(&self) -> builder::ProjectInstancesGetInstance { + builder::ProjectInstancesGetInstance::new(self) + } + + fn project_instances_delete_instance(&self) -> builder::ProjectInstancesDeleteInstance { + builder::ProjectInstancesDeleteInstance::new(self) + } + + fn instance_disks_get(&self) -> builder::InstanceDisksGet { + builder::InstanceDisksGet::new(self) + } + + fn instance_disks_attach(&self) -> builder::InstanceDisksAttach { + builder::InstanceDisksAttach::new(self) + } + + fn instance_disks_detach(&self) -> builder::InstanceDisksDetach { + builder::InstanceDisksDetach::new(self) + } + + fn project_instances_migrate_instance(&self) -> builder::ProjectInstancesMigrateInstance { + builder::ProjectInstancesMigrateInstance::new(self) + } + + fn instance_network_interfaces_get(&self) -> builder::InstanceNetworkInterfacesGet { + builder::InstanceNetworkInterfacesGet::new(self) + } + + fn instance_network_interfaces_post(&self) -> builder::InstanceNetworkInterfacesPost { + builder::InstanceNetworkInterfacesPost::new(self) + } + + fn instance_network_interfaces_get_interface( + &self, + ) -> builder::InstanceNetworkInterfacesGetInterface { + builder::InstanceNetworkInterfacesGetInterface::new(self) + } + + fn instance_network_interfaces_delete_interface( + &self, + ) -> builder::InstanceNetworkInterfacesDeleteInterface { + builder::InstanceNetworkInterfacesDeleteInterface::new(self) + } + + fn project_instances_instance_reboot(&self) -> builder::ProjectInstancesInstanceReboot { + builder::ProjectInstancesInstanceReboot::new(self) + } + + fn project_instances_instance_start(&self) -> builder::ProjectInstancesInstanceStart { + builder::ProjectInstancesInstanceStart::new(self) + } + + fn project_instances_instance_stop(&self) -> builder::ProjectInstancesInstanceStop { + builder::ProjectInstancesInstanceStop::new(self) + } +} + +pub trait ClientMetricsExt { + ///List all 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 retreive 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) + } +} + +pub trait ClientOrganizationsExt { + ///List all organizations + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.organizations_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn organizations_get(&self) -> builder::OrganizationsGet; + ///Create a new organization + /// + ///Sends a `POST` request to `/organizations` + ///```ignore + /// let response = client.organizations_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organizations_post(&self) -> builder::OrganizationsPost; + ///Fetch a specific organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organizations_get_organization() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organizations_get_organization(&self) -> builder::OrganizationsGetOrganization; + ///Update a specific organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organizations_put_organization() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organizations_put_organization(&self) -> builder::OrganizationsPutOrganization; + ///Delete a specific organization + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organizations_delete_organization() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organizations_delete_organization(&self) -> builder::OrganizationsDeleteOrganization; + ///Fetch the IAM policy for this Organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organization_get_policy() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + fn organization_get_policy(&self) -> builder::OrganizationGetPolicy; + ///Update the IAM policy for this Organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organization_put_policy() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_put_policy(&self) -> builder::OrganizationPutPolicy; +} + +impl ClientOrganizationsExt for Client { + fn organizations_get(&self) -> builder::OrganizationsGet { + builder::OrganizationsGet::new(self) + } + + fn organizations_post(&self) -> builder::OrganizationsPost { + builder::OrganizationsPost::new(self) + } + + fn organizations_get_organization(&self) -> builder::OrganizationsGetOrganization { + builder::OrganizationsGetOrganization::new(self) + } + + fn organizations_put_organization(&self) -> builder::OrganizationsPutOrganization { + builder::OrganizationsPutOrganization::new(self) + } + + fn organizations_delete_organization(&self) -> builder::OrganizationsDeleteOrganization { + builder::OrganizationsDeleteOrganization::new(self) + } + + fn organization_get_policy(&self) -> builder::OrganizationGetPolicy { + builder::OrganizationGetPolicy::new(self) + } + + fn organization_put_policy(&self) -> builder::OrganizationPutPolicy { + builder::OrganizationPutPolicy::new(self) + } +} + +pub trait ClientPolicyExt { + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/policy` + ///```ignore + /// let response = client.policy_get() + /// .send() + /// .await; + /// ``` + fn policy_get(&self) -> builder::PolicyGet; + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/policy` + ///```ignore + /// let response = client.policy_put() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn policy_put(&self) -> builder::PolicyPut; +} + +impl ClientPolicyExt for Client { + fn policy_get(&self) -> builder::PolicyGet { + builder::PolicyGet::new(self) + } + + fn policy_put(&self) -> builder::PolicyPut { + builder::PolicyPut::new(self) + } +} + +pub trait ClientProjectsExt { + ///List all projects + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.organization_projects_get() + /// .organization_name(organization_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn organization_projects_get(&self) -> builder::OrganizationProjectsGet; + ///Create a new project + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organization_projects_post() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_projects_post(&self) -> builder::OrganizationProjectsPost; + ///Fetch a specific project + /// + ///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.organization_projects_get_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn organization_projects_get_project(&self) -> builder::OrganizationProjectsGetProject; + ///Update a specific project + /// + ///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.organization_projects_put_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_projects_put_project(&self) -> builder::OrganizationProjectsPutProject; + ///Delete a specific project + /// + ///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.organization_projects_delete_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn organization_projects_delete_project(&self) -> builder::OrganizationProjectsDeleteProject; + ///Fetch the IAM policy for this Project + /// + ///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.organization_projects_get_project_policy() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + fn organization_projects_get_project_policy( + &self, + ) -> builder::OrganizationProjectsGetProjectPolicy; + ///Update the IAM policy for this Project + /// + ///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.organization_projects_put_project_policy() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn organization_projects_put_project_policy( + &self, + ) -> builder::OrganizationProjectsPutProjectPolicy; +} + +impl ClientProjectsExt for Client { + fn organization_projects_get(&self) -> builder::OrganizationProjectsGet { + builder::OrganizationProjectsGet::new(self) + } + + fn organization_projects_post(&self) -> builder::OrganizationProjectsPost { + builder::OrganizationProjectsPost::new(self) + } + + fn organization_projects_get_project(&self) -> builder::OrganizationProjectsGetProject { + builder::OrganizationProjectsGetProject::new(self) + } + + fn organization_projects_put_project(&self) -> builder::OrganizationProjectsPutProject { + builder::OrganizationProjectsPutProject::new(self) + } + + fn organization_projects_delete_project(&self) -> builder::OrganizationProjectsDeleteProject { + builder::OrganizationProjectsDeleteProject::new(self) + } + + fn organization_projects_get_project_policy( + &self, + ) -> builder::OrganizationProjectsGetProjectPolicy { + builder::OrganizationProjectsGetProjectPolicy::new(self) + } + + fn organization_projects_put_project_policy( + &self, + ) -> builder::OrganizationProjectsPutProjectPolicy { + builder::OrganizationProjectsPutProjectPolicy::new(self) + } +} + +pub trait ClientRacksExt { + ///List racks in the system + /// + ///Sends a `GET` request to `/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.hardware_racks_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn hardware_racks_get(&self) -> builder::HardwareRacksGet; + ///Fetch information about a particular rack + /// + ///Sends a `GET` request to `/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + /// + ///```ignore + /// let response = client.hardware_racks_get_rack() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + fn hardware_racks_get_rack(&self) -> builder::HardwareRacksGetRack; +} + +impl ClientRacksExt for Client { + fn hardware_racks_get(&self) -> builder::HardwareRacksGet { + builder::HardwareRacksGet::new(self) + } + + fn hardware_racks_get_rack(&self) -> builder::HardwareRacksGetRack { + builder::HardwareRacksGetRack::new(self) + } +} + +pub trait ClientRolesExt { + ///List the 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 retreive the + /// subsequent page + /// + ///```ignore + /// let response = client.roles_get() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn roles_get(&self) -> builder::RolesGet; + ///Fetch a specific 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.roles_get_role() + /// .role_name(role_name) + /// .send() + /// .await; + /// ``` + fn roles_get_role(&self) -> builder::RolesGetRole; +} + +impl ClientRolesExt for Client { + fn roles_get(&self) -> builder::RolesGet { + builder::RolesGet::new(self) + } + + fn roles_get_role(&self) -> builder::RolesGetRole { + builder::RolesGetRole::new(self) + } +} + +pub trait ClientRoutersExt { + ///List VPC Custom and System 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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.vpc_routers_get() + /// .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_routers_get(&self) -> builder::VpcRoutersGet; + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` ```ignore + /// let response = client.vpc_routers_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_routers_post(&self) -> builder::VpcRoutersPost; + ///Get a VPC Router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_get_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + fn vpc_routers_get_router(&self) -> builder::VpcRoutersGetRouter; + ///Update a VPC Router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_put_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_routers_put_router(&self) -> builder::VpcRoutersPutRouter; + ///Delete a router from its VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_delete_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + fn vpc_routers_delete_router(&self) -> builder::VpcRoutersDeleteRouter; +} + +impl ClientRoutersExt for Client { + fn vpc_routers_get(&self) -> builder::VpcRoutersGet { + builder::VpcRoutersGet::new(self) + } + + fn vpc_routers_post(&self) -> builder::VpcRoutersPost { + builder::VpcRoutersPost::new(self) + } + + fn vpc_routers_get_router(&self) -> builder::VpcRoutersGetRouter { + builder::VpcRoutersGetRouter::new(self) + } + + fn vpc_routers_put_router(&self) -> builder::VpcRoutersPutRouter { + builder::VpcRoutersPutRouter::new(self) + } + + fn vpc_routers_delete_router(&self) -> builder::VpcRoutersDeleteRouter { + builder::VpcRoutersDeleteRouter::new(self) + } +} + +pub trait ClientRoutesExt { + ///List a Router's routes + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.routers_routes_get() + /// .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 routers_routes_get(&self) -> builder::RoutersRoutesGet; + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` ```ignore + /// let response = client.routers_routes_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn routers_routes_post(&self) -> builder::RoutersRoutesPost; + ///Get a VPC Router 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.routers_routes_get_route() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + fn routers_routes_get_route(&self) -> builder::RoutersRoutesGetRoute; + ///Update a Router 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.routers_routes_put_route() + /// .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 routers_routes_put_route(&self) -> builder::RoutersRoutesPutRoute; + ///Delete a route from its router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` ```ignore + /// let response = client.routers_routes_delete_route() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + fn routers_routes_delete_route(&self) -> builder::RoutersRoutesDeleteRoute; +} + +impl ClientRoutesExt for Client { + fn routers_routes_get(&self) -> builder::RoutersRoutesGet { + builder::RoutersRoutesGet::new(self) + } + + fn routers_routes_post(&self) -> builder::RoutersRoutesPost { + builder::RoutersRoutesPost::new(self) + } + + fn routers_routes_get_route(&self) -> builder::RoutersRoutesGetRoute { + builder::RoutersRoutesGetRoute::new(self) + } + + fn routers_routes_put_route(&self) -> builder::RoutersRoutesPutRoute { + builder::RoutersRoutesPutRoute::new(self) + } + + fn routers_routes_delete_route(&self) -> builder::RoutersRoutesDeleteRoute { + builder::RoutersRoutesDeleteRoute::new(self) + } +} + +pub trait ClientSagasExt { + ///List all sagas (for debugging) + /// + ///Sends a `GET` request to `/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.sagas_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sagas_get(&self) -> builder::SagasGet; + ///Fetch information about a single saga (for debugging) + /// + ///Sends a `GET` request to `/sagas/{saga_id}` + ///```ignore + /// let response = client.sagas_get_saga() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + fn sagas_get_saga(&self) -> builder::SagasGetSaga; +} + +impl ClientSagasExt for Client { + fn sagas_get(&self) -> builder::SagasGet { + builder::SagasGet::new(self) + } + + fn sagas_get_saga(&self) -> builder::SagasGetSaga { + builder::SagasGetSaga::new(self) + } +} + +pub trait ClientSilosExt { + ///Sends a `GET` request to `/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.silos_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn silos_get(&self) -> builder::SilosGet; + ///Create a new silo + /// + ///Sends a `POST` request to `/silos` + ///```ignore + /// let response = client.silos_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silos_post(&self) -> builder::SilosPost; + ///Fetch a specific silo + /// + ///Sends a `GET` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_get_silo() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silos_get_silo(&self) -> builder::SilosGetSilo; + ///Delete a specific silo + /// + ///Sends a `DELETE` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_delete_silo() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silos_delete_silo(&self) -> builder::SilosDeleteSilo; + ///Fetch the IAM policy for this Silo + /// + ///Sends a `GET` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_get_silo_policy() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + fn silos_get_silo_policy(&self) -> builder::SilosGetSiloPolicy; + ///Update the IAM policy for this Silo + /// + ///Sends a `PUT` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.silos_put_silo_policy() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn silos_put_silo_policy(&self) -> builder::SilosPutSiloPolicy; +} + +impl ClientSilosExt for Client { + fn silos_get(&self) -> builder::SilosGet { + builder::SilosGet::new(self) + } + + fn silos_post(&self) -> builder::SilosPost { + builder::SilosPost::new(self) + } + + fn silos_get_silo(&self) -> builder::SilosGetSilo { + builder::SilosGetSilo::new(self) + } + + fn silos_delete_silo(&self) -> builder::SilosDeleteSilo { + builder::SilosDeleteSilo::new(self) + } + + fn silos_get_silo_policy(&self) -> builder::SilosGetSiloPolicy { + builder::SilosGetSiloPolicy::new(self) + } + + fn silos_put_silo_policy(&self) -> builder::SilosPutSiloPolicy { + builder::SilosPutSiloPolicy::new(self) + } +} + +pub trait ClientSledsExt { + ///List sleds in the system + /// + ///Sends a `GET` request to `/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.hardware_sleds_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn hardware_sleds_get(&self) -> builder::HardwareSledsGet; + ///Fetch information about a sled in the system + /// + ///Sends a `GET` request to `/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// + ///```ignore + /// let response = client.hardware_sleds_get_sled() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + fn hardware_sleds_get_sled(&self) -> builder::HardwareSledsGetSled; +} + +impl ClientSledsExt for Client { + fn hardware_sleds_get(&self) -> builder::HardwareSledsGet { + builder::HardwareSledsGet::new(self) + } + + fn hardware_sleds_get_sled(&self) -> builder::HardwareSledsGetSled { + builder::HardwareSledsGetSled::new(self) + } +} + +pub trait ClientSnapshotsExt { + ///List snapshots in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_snapshots_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_snapshots_get(&self) -> builder::ProjectSnapshotsGet; + ///Create a snapshot of 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.project_snapshots_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_snapshots_post(&self) -> builder::ProjectSnapshotsPost; + ///Get a snapshot in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` ```ignore + /// let response = client.project_snapshots_get_snapshot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + fn project_snapshots_get_snapshot(&self) -> builder::ProjectSnapshotsGetSnapshot; + ///Delete a snapshot from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` ```ignore + /// let response = client.project_snapshots_delete_snapshot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + fn project_snapshots_delete_snapshot(&self) -> builder::ProjectSnapshotsDeleteSnapshot; +} + +impl ClientSnapshotsExt for Client { + fn project_snapshots_get(&self) -> builder::ProjectSnapshotsGet { + builder::ProjectSnapshotsGet::new(self) + } + + fn project_snapshots_post(&self) -> builder::ProjectSnapshotsPost { + builder::ProjectSnapshotsPost::new(self) + } + + fn project_snapshots_get_snapshot(&self) -> builder::ProjectSnapshotsGetSnapshot { + builder::ProjectSnapshotsGetSnapshot::new(self) + } + + fn project_snapshots_delete_snapshot(&self) -> builder::ProjectSnapshotsDeleteSnapshot { + builder::ProjectSnapshotsDeleteSnapshot::new(self) + } +} + +pub trait ClientSshkeysExt { + ///List the current user's SSH public keys + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.sshkeys_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn sshkeys_get(&self) -> builder::SshkeysGet; + ///Create a new SSH public key for the current user + /// + ///Sends a `POST` request to `/session/me/sshkeys` + ///```ignore + /// let response = client.sshkeys_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn sshkeys_post(&self) -> builder::SshkeysPost; + ///Get (by name) an SSH public key belonging to the current user + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + ///```ignore + /// let response = client.sshkeys_get_key() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + fn sshkeys_get_key(&self) -> builder::SshkeysGetKey; + ///Delete (by name) an SSH public key belonging to the current user + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + ///```ignore + /// let response = client.sshkeys_delete_key() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + fn sshkeys_delete_key(&self) -> builder::SshkeysDeleteKey; +} + +impl ClientSshkeysExt for Client { + fn sshkeys_get(&self) -> builder::SshkeysGet { + builder::SshkeysGet::new(self) + } + + fn sshkeys_post(&self) -> builder::SshkeysPost { + builder::SshkeysPost::new(self) + } + + fn sshkeys_get_key(&self) -> builder::SshkeysGetKey { + builder::SshkeysGetKey::new(self) + } + + fn sshkeys_delete_key(&self) -> builder::SshkeysDeleteKey { + builder::SshkeysDeleteKey::new(self) + } +} + +pub trait ClientSubnetsExt { + ///List subnets in a VPC + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.vpc_subnets_get() + /// .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_subnets_get(&self) -> builder::VpcSubnetsGet; + ///Create a subnet in a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` ```ignore + /// let response = client.vpc_subnets_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_subnets_post(&self) -> builder::VpcSubnetsPost; + ///Get subnet in a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_get_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + fn vpc_subnets_get_subnet(&self) -> builder::VpcSubnetsGetSubnet; + ///Update a VPC Subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_put_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn vpc_subnets_put_subnet(&self) -> builder::VpcSubnetsPutSubnet; + ///Delete a subnet from a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_delete_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + fn vpc_subnets_delete_subnet(&self) -> builder::VpcSubnetsDeleteSubnet; + ///List network interfaces in a VPC subnet + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.subnet_network_interfaces_get() + /// .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 subnet_network_interfaces_get(&self) -> builder::SubnetNetworkInterfacesGet; +} + +impl ClientSubnetsExt for Client { + fn vpc_subnets_get(&self) -> builder::VpcSubnetsGet { + builder::VpcSubnetsGet::new(self) + } + + fn vpc_subnets_post(&self) -> builder::VpcSubnetsPost { + builder::VpcSubnetsPost::new(self) + } + + fn vpc_subnets_get_subnet(&self) -> builder::VpcSubnetsGetSubnet { + builder::VpcSubnetsGetSubnet::new(self) + } + + fn vpc_subnets_put_subnet(&self) -> builder::VpcSubnetsPutSubnet { + builder::VpcSubnetsPutSubnet::new(self) + } + + fn vpc_subnets_delete_subnet(&self) -> builder::VpcSubnetsDeleteSubnet { + builder::VpcSubnetsDeleteSubnet::new(self) + } + + fn subnet_network_interfaces_get(&self) -> builder::SubnetNetworkInterfacesGet { + builder::SubnetNetworkInterfacesGet::new(self) + } +} + +pub trait ClientUpdatesExt { + ///Refresh update metadata + /// + ///Sends a `POST` request to `/updates/refresh` + ///```ignore + /// let response = client.updates_refresh() + /// .send() + /// .await; + /// ``` + fn updates_refresh(&self) -> builder::UpdatesRefresh; +} + +impl ClientUpdatesExt for Client { + fn updates_refresh(&self) -> builder::UpdatesRefresh { + builder::UpdatesRefresh::new(self) + } +} + +pub trait ClientUsersExt { + ///List the built-in system 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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.users_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn users_get(&self) -> builder::UsersGet; + ///Fetch a specific built-in system user + /// + ///Sends a `GET` request to `/users/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. + /// + ///```ignore + /// let response = client.users_get_user() + /// .user_name(user_name) + /// .send() + /// .await; + /// ``` + fn users_get_user(&self) -> builder::UsersGetUser; +} + +impl ClientUsersExt for Client { + fn users_get(&self) -> builder::UsersGet { + builder::UsersGet::new(self) + } + + fn users_get_user(&self) -> builder::UsersGetUser { + builder::UsersGetUser::new(self) + } +} + +pub trait ClientVpcsExt { + ///List VPCs in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_vpcs_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + fn project_vpcs_get(&self) -> builder::ProjectVpcsGet; + ///Create a VPC in a project + /// + ///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.project_vpcs_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_vpcs_post(&self) -> builder::ProjectVpcsPost; + ///Get a VPC in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_get_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn project_vpcs_get_vpc(&self) -> builder::ProjectVpcsGetVpc; + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_put_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + fn project_vpcs_put_vpc(&self) -> builder::ProjectVpcsPutVpc; + ///Delete a vpc from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_delete_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + fn project_vpcs_delete_vpc(&self) -> builder::ProjectVpcsDeleteVpc; +} + +impl ClientVpcsExt for Client { + fn project_vpcs_get(&self) -> builder::ProjectVpcsGet { + builder::ProjectVpcsGet::new(self) + } + + fn project_vpcs_post(&self) -> builder::ProjectVpcsPost { + builder::ProjectVpcsPost::new(self) + } + + fn project_vpcs_get_vpc(&self) -> builder::ProjectVpcsGetVpc { + builder::ProjectVpcsGetVpc::new(self) + } + + fn project_vpcs_put_vpc(&self) -> builder::ProjectVpcsPutVpc { + builder::ProjectVpcsPutVpc::new(self) + } + + fn project_vpcs_delete_vpc(&self) -> builder::ProjectVpcsDeleteVpc { + builder::ProjectVpcsDeleteVpc::new(self) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`ClientRacksExt::hardware_racks_get`] + /// + ///[`ClientRacksExt::hardware_racks_get`]: super::ClientRacksExt::hardware_racks_get + #[derive(Clone)] + pub struct HardwareRacksGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> HardwareRacksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/hardware/racks", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientRacksExt::hardware_racks_get_rack`] + /// + ///[`ClientRacksExt::hardware_racks_get_rack`]: super::ClientRacksExt::hardware_racks_get_rack + #[derive(Clone)] + pub struct HardwareRacksGetRack<'a> { + client: &'a super::Client, + rack_id: Option, + } + + impl<'a> HardwareRacksGetRack<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + rack_id: None, + } + } + + pub fn rack_id(mut self, value: uuid::Uuid) -> Self { + self.rack_id = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let (rack_id,) = match (rack_id,) { + (Some(rack_id),) => (rack_id,), + (rack_id,) => { + let mut missing = Vec::new(); + if rack_id.is_none() { + missing.push(stringify!(rack_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSledsExt::hardware_sleds_get`] + /// + ///[`ClientSledsExt::hardware_sleds_get`]: super::ClientSledsExt::hardware_sleds_get + #[derive(Clone)] + pub struct HardwareSledsGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> HardwareSledsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/hardware/sleds", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSledsExt::hardware_sleds_get_sled`] + /// + ///[`ClientSledsExt::hardware_sleds_get_sled`]: super::ClientSledsExt::hardware_sleds_get_sled + #[derive(Clone)] + pub struct HardwareSledsGetSled<'a> { + client: &'a super::Client, + sled_id: Option, + } + + impl<'a> HardwareSledsGetSled<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: None, + } + } + + pub fn sled_id(mut self, value: uuid::Uuid) -> Self { + self.sled_id = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let (sled_id,) = match (sled_id,) { + (Some(sled_id),) => (sled_id,), + (sled_id,) => { + let mut missing = Vec::new(); + if sled_id.is_none() { + missing.push(stringify!(sled_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientImagesGlobalExt::images_get`] + /// + ///[`ClientImagesGlobalExt::images_get`]: super::ClientImagesGlobalExt::images_get + #[derive(Clone)] + pub struct ImagesGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ImagesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/images", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientImagesGlobalExt::images_post`] + /// + ///[`ClientImagesGlobalExt::images_post`]: super::ClientImagesGlobalExt::images_post + #[derive(Clone)] + pub struct ImagesPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ImagesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ImageCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/images", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientImagesGlobalExt::images_get_image`] + /// + ///[`ClientImagesGlobalExt::images_get_image`]: super::ClientImagesGlobalExt::images_get_image + #[derive(Clone)] + pub struct ImagesGetImage<'a> { + client: &'a super::Client, + image_name: Option, + } + + impl<'a> ImagesGetImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: None, + } + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + self + } + + ///Sends a `GET` request to `/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let (image_name,) = match (image_name,) { + (Some(image_name),) => (image_name,), + (image_name,) => { + let mut missing = Vec::new(); + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientImagesGlobalExt::images_delete_image`] + /// + ///[`ClientImagesGlobalExt::images_delete_image`]: super::ClientImagesGlobalExt::images_delete_image + #[derive(Clone)] + pub struct ImagesDeleteImage<'a> { + client: &'a super::Client, + image_name: Option, + } + + impl<'a> ImagesDeleteImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: None, + } + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + self + } + + ///Sends a `DELETE` request to `/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let (image_name,) = match (image_name,) { + (Some(image_name),) => (image_name,), + (image_name,) => { + let mut missing = Vec::new(); + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::spoof_login`] + /// + ///[`ClientHiddenExt::spoof_login`]: super::ClientHiddenExt::spoof_login + #[derive(Clone)] + pub struct SpoofLogin<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SpoofLogin<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::LoginParams) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/login` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/login", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`ClientHiddenExt::logout`] + /// + ///[`ClientHiddenExt::logout`]: super::ClientHiddenExt::logout + #[derive(Clone)] + pub struct Logout<'a> { + client: &'a super::Client, + } + + impl<'a> Logout<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`ClientOrganizationsExt::organizations_get`] + /// + ///[`ClientOrganizationsExt::organizations_get`]: super::ClientOrganizationsExt::organizations_get + #[derive(Clone)] + pub struct OrganizationsGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> OrganizationsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/organizations", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientOrganizationsExt::organizations_post`] + /// + ///[`ClientOrganizationsExt::organizations_post`]: super::ClientOrganizationsExt::organizations_post + #[derive(Clone)] + pub struct OrganizationsPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> OrganizationsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::OrganizationCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/organizations", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::organizations_get_organization`] + /// + ///[`ClientOrganizationsExt::organizations_get_organization`]: super::ClientOrganizationsExt::organizations_get_organization + #[derive(Clone)] + pub struct OrganizationsGetOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationsGetOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organizations_put_organization`] + /// + ///[`ClientOrganizationsExt::organizations_put_organization`]: super::ClientOrganizationsExt::organizations_put_organization + #[derive(Clone)] + pub struct OrganizationsPutOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationsPutOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::OrganizationUpdate) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organizations_delete_organization`] + /// + ///[`ClientOrganizationsExt::organizations_delete_organization`]: super::ClientOrganizationsExt::organizations_delete_organization + #[derive(Clone)] + pub struct OrganizationsDeleteOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationsDeleteOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_get_policy`] + /// + ///[`ClientOrganizationsExt::organization_get_policy`]: super::ClientOrganizationsExt::organization_get_policy + #[derive(Clone)] + pub struct OrganizationGetPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationGetPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_put_policy`] + /// + ///[`ClientOrganizationsExt::organization_put_policy`]: super::ClientOrganizationsExt::organization_put_policy + #[derive(Clone)] + pub struct OrganizationPutPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationPutPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::OrganizationRolesPolicy) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organization_projects_get`] + /// + ///[`ClientProjectsExt::organization_projects_get`]: super::ClientProjectsExt::organization_projects_get + #[derive(Clone)] + pub struct OrganizationProjectsGet<'a> { + client: &'a super::Client, + organization_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> OrganizationProjectsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientProjectsExt::organization_projects_post`] + /// + ///[`ClientProjectsExt::organization_projects_post`]: super::ClientProjectsExt::organization_projects_post + #[derive(Clone)] + pub struct OrganizationProjectsPost<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectCreate) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::organization_projects_get_project`] + /// + ///[`ClientProjectsExt::organization_projects_get_project`]: super::ClientProjectsExt::organization_projects_get_project + #[derive(Clone)] + pub struct OrganizationProjectsGetProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsGetProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organization_projects_put_project`] + /// + ///[`ClientProjectsExt::organization_projects_put_project`]: super::ClientProjectsExt::organization_projects_put_project + #[derive(Clone)] + pub struct OrganizationProjectsPutProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPutProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectUpdate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organization_projects_delete_project`] + /// + ///[`ClientProjectsExt::organization_projects_delete_project`]: super::ClientProjectsExt::organization_projects_delete_project + #[derive(Clone)] + pub struct OrganizationProjectsDeleteProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsDeleteProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_disks_get`] + /// + ///[`ClientDisksExt::project_disks_get`]: super::ClientDisksExt::project_disks_get + #[derive(Clone)] + pub struct ProjectDisksGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectDisksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientDisksExt::project_disks_post`] + /// + ///[`ClientDisksExt::project_disks_post`]: super::ClientDisksExt::project_disks_post + #[derive(Clone)] + pub struct ProjectDisksPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectDisksPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_disks_get_disk`] + /// + ///[`ClientDisksExt::project_disks_get_disk`]: super::ClientDisksExt::project_disks_get_disk + #[derive(Clone)] + pub struct ProjectDisksGetDisk<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + disk_name: Option, + } + + impl<'a> ProjectDisksGetDisk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + disk_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn disk_name(mut self, value: types::Name) -> Self { + self.disk_name = Some(value); + 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, project_name, disk_name) = + match (organization_name, project_name, disk_name) { + (Some(organization_name), Some(project_name), Some(disk_name)) => { + (organization_name, project_name, disk_name) + } + (organization_name, project_name, disk_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if disk_name.is_none() { + missing.push(stringify!(disk_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_disks_delete_disk`] + /// + ///[`ClientDisksExt::project_disks_delete_disk`]: super::ClientDisksExt::project_disks_delete_disk + #[derive(Clone)] + pub struct ProjectDisksDeleteDisk<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + disk_name: Option, + } + + impl<'a> ProjectDisksDeleteDisk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + disk_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn disk_name(mut self, value: types::Name) -> Self { + self.disk_name = Some(value); + 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, project_name, disk_name) = + match (organization_name, project_name, disk_name) { + (Some(organization_name), Some(project_name), Some(disk_name)) => { + (organization_name, project_name, disk_name) + } + (organization_name, project_name, disk_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if disk_name.is_none() { + missing.push(stringify!(disk_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientImagesExt::project_images_get`] + /// + ///[`ClientImagesExt::project_images_get`]: super::ClientImagesExt::project_images_get + #[derive(Clone)] + pub struct ProjectImagesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectImagesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientImagesExt::project_images_post`] + /// + ///[`ClientImagesExt::project_images_post`]: super::ClientImagesExt::project_images_post + #[derive(Clone)] + pub struct ProjectImagesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectImagesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ImageCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_images_get_image`] + /// + ///[`ClientImagesExt::project_images_get_image`]: super::ClientImagesExt::project_images_get_image + #[derive(Clone)] + pub struct ProjectImagesGetImage<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + image_name: Option, + } + + impl<'a> ProjectImagesGetImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + image_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + 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, project_name, image_name) = + match (organization_name, project_name, image_name) { + (Some(organization_name), Some(project_name), Some(image_name)) => { + (organization_name, project_name, image_name) + } + (organization_name, project_name, image_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_images_delete_image`] + /// + ///[`ClientImagesExt::project_images_delete_image`]: super::ClientImagesExt::project_images_delete_image + #[derive(Clone)] + pub struct ProjectImagesDeleteImage<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + image_name: Option, + } + + impl<'a> ProjectImagesDeleteImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + image_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + 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, project_name, image_name) = + match (organization_name, project_name, image_name) { + (Some(organization_name), Some(project_name), Some(image_name)) => { + (organization_name, project_name, image_name) + } + (organization_name, project_name, image_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_get`] + /// + ///[`ClientInstancesExt::project_instances_get`]: super::ClientInstancesExt::project_instances_get + #[derive(Clone)] + pub struct ProjectInstancesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectInstancesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientInstancesExt::project_instances_post`] + /// + ///[`ClientInstancesExt::project_instances_post`]: super::ClientInstancesExt::project_instances_post + #[derive(Clone)] + pub struct ProjectInstancesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectInstancesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::InstanceCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_get_instance`] + /// + ///[`ClientInstancesExt::project_instances_get_instance`]: super::ClientInstancesExt::project_instances_get_instance + #[derive(Clone)] + pub struct ProjectInstancesGetInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesGetInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_instances_delete_instance`] + /// + ///[`ClientInstancesExt::project_instances_delete_instance`]: super::ClientInstancesExt::project_instances_delete_instance + #[derive(Clone)] + pub struct ProjectInstancesDeleteInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesDeleteInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_get`] + /// + ///[`ClientInstancesExt::instance_disks_get`]: super::ClientInstancesExt::instance_disks_get + #[derive(Clone)] + pub struct InstanceDisksGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> InstanceDisksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientInstancesExt::instance_disks_attach`] + /// + ///[`ClientInstancesExt::instance_disks_attach`]: super::ClientInstancesExt::instance_disks_attach + #[derive(Clone)] + pub struct InstanceDisksAttach<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceDisksAttach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskIdentifier) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_detach`] + /// + ///[`ClientInstancesExt::instance_disks_detach`]: super::ClientInstancesExt::instance_disks_detach + #[derive(Clone)] + pub struct InstanceDisksDetach<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceDisksDetach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskIdentifier) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_migrate_instance`] + /// + ///[`ClientInstancesExt::project_instances_migrate_instance`]: super::ClientInstancesExt::project_instances_migrate_instance + #[derive(Clone)] + pub struct ProjectInstancesMigrateInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> ProjectInstancesMigrateInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::InstanceMigrate) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_interfaces_get`] + /// + ///[`ClientInstancesExt::instance_network_interfaces_get`]: super::ClientInstancesExt::instance_network_interfaces_get + #[derive(Clone)] + pub struct InstanceNetworkInterfacesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> InstanceNetworkInterfacesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientInstancesExt::instance_network_interfaces_post`] + /// + ///[`ClientInstancesExt::instance_network_interfaces_post`]: super::ClientInstancesExt::instance_network_interfaces_post + #[derive(Clone)] + pub struct InstanceNetworkInterfacesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceNetworkInterfacesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::NetworkInterfaceCreate) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_interfaces_get_interface`] + /// + ///[`ClientInstancesExt::instance_network_interfaces_get_interface`]: super::ClientInstancesExt::instance_network_interfaces_get_interface + #[derive(Clone)] + pub struct InstanceNetworkInterfacesGetInterface<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + interface_name: Option, + } + + impl<'a> InstanceNetworkInterfacesGetInterface<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + interface_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn interface_name(mut self, value: types::Name) -> Self { + self.interface_name = Some(value); + 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, project_name, instance_name, interface_name) = match ( + organization_name, + project_name, + instance_name, + interface_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(interface_name), + ) => ( + organization_name, + project_name, + instance_name, + interface_name, + ), + (organization_name, project_name, instance_name, interface_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if interface_name.is_none() { + missing.push(stringify!(interface_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_interfaces_delete_interface`] + /// + ///[`ClientInstancesExt::instance_network_interfaces_delete_interface`]: super::ClientInstancesExt::instance_network_interfaces_delete_interface + #[derive(Clone)] + pub struct InstanceNetworkInterfacesDeleteInterface<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + interface_name: Option, + } + + impl<'a> InstanceNetworkInterfacesDeleteInterface<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + interface_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn interface_name(mut self, value: types::Name) -> Self { + self.interface_name = Some(value); + 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, project_name, instance_name, interface_name) = match ( + organization_name, + project_name, + instance_name, + interface_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(interface_name), + ) => ( + organization_name, + project_name, + instance_name, + interface_name, + ), + (organization_name, project_name, instance_name, interface_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if interface_name.is_none() { + missing.push(stringify!(interface_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_instance_reboot`] + /// + ///[`ClientInstancesExt::project_instances_instance_reboot`]: super::ClientInstancesExt::project_instances_instance_reboot + #[derive(Clone)] + pub struct ProjectInstancesInstanceReboot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceReboot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_instance_start`] + /// + ///[`ClientInstancesExt::project_instances_instance_start`]: super::ClientInstancesExt::project_instances_instance_start + #[derive(Clone)] + pub struct ProjectInstancesInstanceStart<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_instances_instance_stop`] + /// + ///[`ClientInstancesExt::project_instances_instance_stop`]: super::ClientInstancesExt::project_instances_instance_stop + #[derive(Clone)] + pub struct ProjectInstancesInstanceStop<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::organization_projects_get_project_policy`] + /// + ///[`ClientProjectsExt::organization_projects_get_project_policy`]: super::ClientProjectsExt::organization_projects_get_project_policy + #[derive(Clone)] + pub struct OrganizationProjectsGetProjectPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsGetProjectPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organization_projects_put_project_policy`] + /// + ///[`ClientProjectsExt::organization_projects_put_project_policy`]: super::ClientProjectsExt::organization_projects_put_project_policy + #[derive(Clone)] + pub struct OrganizationProjectsPutProjectPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPutProjectPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectRolesPolicy) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_snapshots_get`] + /// + ///[`ClientSnapshotsExt::project_snapshots_get`]: super::ClientSnapshotsExt::project_snapshots_get + #[derive(Clone)] + pub struct ProjectSnapshotsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectSnapshotsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSnapshotsExt::project_snapshots_post`] + /// + ///[`ClientSnapshotsExt::project_snapshots_post`]: super::ClientSnapshotsExt::project_snapshots_post + #[derive(Clone)] + pub struct ProjectSnapshotsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectSnapshotsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::SnapshotCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_snapshots_get_snapshot`] + /// + ///[`ClientSnapshotsExt::project_snapshots_get_snapshot`]: super::ClientSnapshotsExt::project_snapshots_get_snapshot + #[derive(Clone)] + pub struct ProjectSnapshotsGetSnapshot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + snapshot_name: Option, + } + + impl<'a> ProjectSnapshotsGetSnapshot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + snapshot_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn snapshot_name(mut self, value: types::Name) -> Self { + self.snapshot_name = Some(value); + 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, project_name, snapshot_name) = + match (organization_name, project_name, snapshot_name) { + (Some(organization_name), Some(project_name), Some(snapshot_name)) => { + (organization_name, project_name, snapshot_name) + } + (organization_name, project_name, snapshot_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if snapshot_name.is_none() { + missing.push(stringify!(snapshot_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_snapshots_delete_snapshot`] + /// + ///[`ClientSnapshotsExt::project_snapshots_delete_snapshot`]: super::ClientSnapshotsExt::project_snapshots_delete_snapshot + #[derive(Clone)] + pub struct ProjectSnapshotsDeleteSnapshot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + snapshot_name: Option, + } + + impl<'a> ProjectSnapshotsDeleteSnapshot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + snapshot_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn snapshot_name(mut self, value: types::Name) -> Self { + self.snapshot_name = Some(value); + 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, project_name, snapshot_name) = + match (organization_name, project_name, snapshot_name) { + (Some(organization_name), Some(project_name), Some(snapshot_name)) => { + (organization_name, project_name, snapshot_name) + } + (organization_name, project_name, snapshot_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if snapshot_name.is_none() { + missing.push(stringify!(snapshot_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_vpcs_get`] + /// + ///[`ClientVpcsExt::project_vpcs_get`]: super::ClientVpcsExt::project_vpcs_get + #[derive(Clone)] + pub struct ProjectVpcsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectVpcsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientVpcsExt::project_vpcs_post`] + /// + ///[`ClientVpcsExt::project_vpcs_post`]: super::ClientVpcsExt::project_vpcs_post + #[derive(Clone)] + pub struct ProjectVpcsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectVpcsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::project_vpcs_get_vpc`] + /// + ///[`ClientVpcsExt::project_vpcs_get_vpc`]: super::ClientVpcsExt::project_vpcs_get_vpc + #[derive(Clone)] + pub struct ProjectVpcsGetVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> ProjectVpcsGetVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_vpcs_put_vpc`] + /// + ///[`ClientVpcsExt::project_vpcs_put_vpc`]: super::ClientVpcsExt::project_vpcs_put_vpc + #[derive(Clone)] + pub struct ProjectVpcsPutVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> ProjectVpcsPutVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::project_vpcs_delete_vpc`] + /// + ///[`ClientVpcsExt::project_vpcs_delete_vpc`]: super::ClientVpcsExt::project_vpcs_delete_vpc + #[derive(Clone)] + pub struct ProjectVpcsDeleteVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> ProjectVpcsDeleteVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientFirewallExt::vpc_firewall_rules_get`] + /// + ///[`ClientFirewallExt::vpc_firewall_rules_get`]: super::ClientFirewallExt::vpc_firewall_rules_get + #[derive(Clone)] + pub struct VpcFirewallRulesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> VpcFirewallRulesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientFirewallExt::vpc_firewall_rules_put`] + /// + ///[`ClientFirewallExt::vpc_firewall_rules_put`]: super::ClientFirewallExt::vpc_firewall_rules_put + #[derive(Clone)] + pub struct VpcFirewallRulesPut<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcFirewallRulesPut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcFirewallRuleUpdateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRoutersExt::vpc_routers_get`] + /// + ///[`ClientRoutersExt::vpc_routers_get`]: super::ClientRoutersExt::vpc_routers_get + #[derive(Clone)] + pub struct VpcRoutersGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> VpcRoutersGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientRoutersExt::vpc_routers_post`] + /// + ///[`ClientRoutersExt::vpc_routers_post`]: super::ClientRoutersExt::vpc_routers_post + #[derive(Clone)] + pub struct VpcRoutersPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcRoutersPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcRouterCreate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientRoutersExt::vpc_routers_get_router`] + /// + ///[`ClientRoutersExt::vpc_routers_get_router`]: super::ClientRoutersExt::vpc_routers_get_router + #[derive(Clone)] + pub struct VpcRoutersGetRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + } + + impl<'a> VpcRoutersGetRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRoutersExt::vpc_routers_put_router`] + /// + ///[`ClientRoutersExt::vpc_routers_put_router`]: super::ClientRoutersExt::vpc_routers_put_router + #[derive(Clone)] + pub struct VpcRoutersPutRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + body: Option, + } + + impl<'a> VpcRoutersPutRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcRouterUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, body) = + match (organization_name, project_name, vpc_name, router_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(body), + ) => (organization_name, project_name, vpc_name, router_name, body), + (organization_name, project_name, vpc_name, router_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRoutersExt::vpc_routers_delete_router`] + /// + ///[`ClientRoutersExt::vpc_routers_delete_router`]: super::ClientRoutersExt::vpc_routers_delete_router + #[derive(Clone)] + pub struct VpcRoutersDeleteRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + } + + impl<'a> VpcRoutersDeleteRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientRoutesExt::routers_routes_get`] + /// + ///[`ClientRoutesExt::routers_routes_get`]: super::ClientRoutesExt::routers_routes_get + #[derive(Clone)] + pub struct RoutersRoutesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> RoutersRoutesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientRoutesExt::routers_routes_post`] + /// + ///[`ClientRoutesExt::routers_routes_post`]: super::ClientRoutesExt::routers_routes_post + #[derive(Clone)] + pub struct RoutersRoutesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + body: Option, + } + + impl<'a> RoutersRoutesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn body(mut self, value: types::RouterRouteCreateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, body) = + match (organization_name, project_name, vpc_name, router_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(body), + ) => (organization_name, project_name, vpc_name, router_name, body), + (organization_name, project_name, vpc_name, router_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientRoutesExt::routers_routes_get_route`] + /// + ///[`ClientRoutesExt::routers_routes_get_route`]: super::ClientRoutesExt::routers_routes_get_route + #[derive(Clone)] + pub struct RoutersRoutesGetRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + } + + impl<'a> RoutersRoutesGetRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + 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, project_name, vpc_name, router_name, route_name) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ), + (organization_name, project_name, vpc_name, router_name, route_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRoutesExt::routers_routes_put_route`] + /// + ///[`ClientRoutesExt::routers_routes_put_route`]: super::ClientRoutesExt::routers_routes_put_route + #[derive(Clone)] + pub struct RoutersRoutesPutRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + body: Option, + } + + impl<'a> RoutersRoutesPutRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + self + } + + pub fn body(mut self, value: types::RouterRouteUpdateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, route_name, body) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + Some(body), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + ), + (organization_name, project_name, vpc_name, router_name, route_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientRoutesExt::routers_routes_delete_route`] + /// + ///[`ClientRoutesExt::routers_routes_delete_route`]: super::ClientRoutesExt::routers_routes_delete_route + #[derive(Clone)] + pub struct RoutersRoutesDeleteRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + } + + impl<'a> RoutersRoutesDeleteRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + 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, project_name, vpc_name, router_name, route_name) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ), + (organization_name, project_name, vpc_name, router_name, route_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSubnetsExt::vpc_subnets_get`] + /// + ///[`ClientSubnetsExt::vpc_subnets_get`]: super::ClientSubnetsExt::vpc_subnets_get + #[derive(Clone)] + pub struct VpcSubnetsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> VpcSubnetsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSubnetsExt::vpc_subnets_post`] + /// + ///[`ClientSubnetsExt::vpc_subnets_post`]: super::ClientSubnetsExt::vpc_subnets_post + #[derive(Clone)] + pub struct VpcSubnetsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcSubnetsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcSubnetCreate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSubnetsExt::vpc_subnets_get_subnet`] + /// + ///[`ClientSubnetsExt::vpc_subnets_get_subnet`]: super::ClientSubnetsExt::vpc_subnets_get_subnet + #[derive(Clone)] + pub struct VpcSubnetsGetSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + } + + impl<'a> VpcSubnetsGetSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSubnetsExt::vpc_subnets_put_subnet`] + /// + ///[`ClientSubnetsExt::vpc_subnets_put_subnet`]: super::ClientSubnetsExt::vpc_subnets_put_subnet + #[derive(Clone)] + pub struct VpcSubnetsPutSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + body: Option, + } + + impl<'a> VpcSubnetsPutSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcSubnetUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, subnet_name, body) = + match (organization_name, project_name, vpc_name, subnet_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + Some(body), + ) => (organization_name, project_name, vpc_name, subnet_name, body), + (organization_name, project_name, vpc_name, subnet_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSubnetsExt::vpc_subnets_delete_subnet`] + /// + ///[`ClientSubnetsExt::vpc_subnets_delete_subnet`]: super::ClientSubnetsExt::vpc_subnets_delete_subnet + #[derive(Clone)] + pub struct VpcSubnetsDeleteSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + } + + impl<'a> VpcSubnetsDeleteSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSubnetsExt::subnet_network_interfaces_get`] + /// + ///[`ClientSubnetsExt::subnet_network_interfaces_get`]: super::ClientSubnetsExt::subnet_network_interfaces_get + #[derive(Clone)] + pub struct SubnetNetworkInterfacesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SubnetNetworkInterfacesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientPolicyExt::policy_get`] + /// + ///[`ClientPolicyExt::policy_get`]: super::ClientPolicyExt::policy_get + #[derive(Clone)] + pub struct PolicyGet<'a> { + client: &'a super::Client, + } + + impl<'a> PolicyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::policy_put`] + /// + ///[`ClientPolicyExt::policy_put`]: super::ClientPolicyExt::policy_put + #[derive(Clone)] + pub struct PolicyPut<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> PolicyPut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::FleetRolesPolicy) -> Self { + self.body = Some(value); + self + } + + ///Sends a `PUT` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/policy", client.baseurl,); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::roles_get`] + /// + ///[`ClientRolesExt::roles_get`]: super::ClientRolesExt::roles_get + #[derive(Clone)] + pub struct RolesGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + } + + impl<'a> RolesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + ///Sends a `GET` request to `/roles` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let url = format!("{}/roles", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientRolesExt::roles_get_role`] + /// + ///[`ClientRolesExt::roles_get_role`]: super::ClientRolesExt::roles_get_role + #[derive(Clone)] + pub struct RolesGetRole<'a> { + client: &'a super::Client, + role_name: Option, + } + + impl<'a> RolesGetRole<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + role_name: None, + } + } + + pub fn role_name(mut self, value: S) -> Self { + self.role_name = Some(value.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,) = match (role_name,) { + (Some(role_name),) => (role_name,), + (role_name,) => { + let mut missing = Vec::new(); + if role_name.is_none() { + missing.push(stringify!(role_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/roles/{}", + client.baseurl, + encode_path(&role_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSagasExt::sagas_get`] + /// + ///[`ClientSagasExt::sagas_get`]: super::ClientSagasExt::sagas_get + #[derive(Clone)] + pub struct SagasGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SagasGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/sagas", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSagasExt::sagas_get_saga`] + /// + ///[`ClientSagasExt::sagas_get_saga`]: super::ClientSagasExt::sagas_get_saga + #[derive(Clone)] + pub struct SagasGetSaga<'a> { + client: &'a super::Client, + saga_id: Option, + } + + impl<'a> SagasGetSaga<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + saga_id: None, + } + } + + pub fn saga_id(mut self, value: uuid::Uuid) -> Self { + self.saga_id = Some(value); + self + } + + ///Sends a `GET` request to `/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let (saga_id,) = match (saga_id,) { + (Some(saga_id),) => (saga_id,), + (saga_id,) => { + let mut missing = Vec::new(); + if saga_id.is_none() { + missing.push(stringify!(saga_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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(Clone)] + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSshkeysExt::sshkeys_get`] + /// + ///[`ClientSshkeysExt::sshkeys_get`]: super::ClientSshkeysExt::sshkeys_get + #[derive(Clone)] + pub struct SshkeysGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SshkeysGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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 url = format!("{}/session/me/sshkeys", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSshkeysExt::sshkeys_post`] + /// + ///[`ClientSshkeysExt::sshkeys_post`]: super::ClientSshkeysExt::sshkeys_post + #[derive(Clone)] + pub struct SshkeysPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SshkeysPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::SshKeyCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/session/me/sshkeys` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSshkeysExt::sshkeys_get_key`] + /// + ///[`ClientSshkeysExt::sshkeys_get_key`]: super::ClientSshkeysExt::sshkeys_get_key + #[derive(Clone)] + pub struct SshkeysGetKey<'a> { + client: &'a super::Client, + ssh_key_name: Option, + } + + impl<'a> SshkeysGetKey<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + ssh_key_name: None, + } + } + + pub fn ssh_key_name(mut self, value: types::Name) -> Self { + self.ssh_key_name = Some(value); + 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,) = match (ssh_key_name,) { + (Some(ssh_key_name),) => (ssh_key_name,), + (ssh_key_name,) => { + let mut missing = Vec::new(); + if ssh_key_name.is_none() { + missing.push(stringify!(ssh_key_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + ///Builder for [`ClientSshkeysExt::sshkeys_delete_key`] + /// + ///[`ClientSshkeysExt::sshkeys_delete_key`]: super::ClientSshkeysExt::sshkeys_delete_key + #[derive(Clone)] + pub struct SshkeysDeleteKey<'a> { + client: &'a super::Client, + ssh_key_name: Option, + } + + impl<'a> SshkeysDeleteKey<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + ssh_key_name: None, + } + } + + pub fn ssh_key_name(mut self, value: types::Name) -> Self { + self.ssh_key_name = Some(value); + 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,) = match (ssh_key_name,) { + (Some(ssh_key_name),) => (ssh_key_name,), + (ssh_key_name,) => { + let mut missing = Vec::new(); + if ssh_key_name.is_none() { + missing.push(stringify!(ssh_key_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSilosExt::silos_get`] + /// + ///[`ClientSilosExt::silos_get`]: super::ClientSilosExt::silos_get + #[derive(Clone)] + pub struct SilosGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SilosGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/silos` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/silos", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/silos` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientSilosExt::silos_post`] + /// + ///[`ClientSilosExt::silos_post`]: super::ClientSilosExt::silos_post + #[derive(Clone)] + pub struct SilosPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SilosPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::SiloCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/silos` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/silos", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSilosExt::silos_get_silo`] + /// + ///[`ClientSilosExt::silos_get_silo`]: super::ClientSilosExt::silos_get_silo + #[derive(Clone)] + pub struct SilosGetSilo<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosGetSilo<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `GET` request to `/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::silos_delete_silo`] + /// + ///[`ClientSilosExt::silos_delete_silo`]: super::ClientSilosExt::silos_delete_silo + #[derive(Clone)] + pub struct SilosDeleteSilo<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosDeleteSilo<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `DELETE` request to `/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientSilosExt::silos_get_silo_policy`] + /// + ///[`ClientSilosExt::silos_get_silo_policy`]: super::ClientSilosExt::silos_get_silo_policy + #[derive(Clone)] + pub struct SilosGetSiloPolicy<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosGetSiloPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `GET` request to `/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::silos_put_silo_policy`] + /// + ///[`ClientSilosExt::silos_put_silo_policy`]: super::ClientSilosExt::silos_put_silo_policy + #[derive(Clone)] + pub struct SilosPutSiloPolicy<'a> { + client: &'a super::Client, + silo_name: Option, + body: Option, + } + + impl<'a> SilosPutSiloPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + body: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + pub fn body(mut self, value: types::SiloRolesPolicy) -> Self { + self.body = Some(value); + self + } + + ///Sends a `PUT` request to `/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let (silo_name, body) = match (silo_name, body) { + (Some(silo_name), Some(body)) => (silo_name, body), + (silo_name, body) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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(Clone)] + pub struct TimeseriesSchemaGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + } + + impl<'a> TimeseriesSchemaGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + ///Sends a `GET` request to `/timeseries/schema` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + } = self; + let url = format!("{}/timeseries/schema", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientUpdatesExt::updates_refresh`] + /// + ///[`ClientUpdatesExt::updates_refresh`]: super::ClientUpdatesExt::updates_refresh + #[derive(Clone)] + pub struct UpdatesRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> UpdatesRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/updates/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/updates/refresh", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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 [`ClientUsersExt::users_get`] + /// + ///[`ClientUsersExt::users_get`]: super::ClientUsersExt::users_get + #[derive(Clone)] + pub struct UsersGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> UsersGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/users", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`ClientUsersExt::users_get_user`] + /// + ///[`ClientUsersExt::users_get_user`]: super::ClientUsersExt::users_get_user + #[derive(Clone)] + pub struct UsersGetUser<'a> { + client: &'a super::Client, + user_name: Option, + } + + impl<'a> UsersGetUser<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + user_name: None, + } + } + + pub fn user_name(mut self, value: types::Name) -> Self { + self.user_name = Some(value); + self + } + + ///Sends a `GET` request to `/users/{user_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, user_name } = self; + let (user_name,) = match (user_name,) { + (Some(user_name),) => (user_name,), + (user_name,) => { + let mut missing = Vec::new(); + if user_name.is_none() { + missing.push(stringify!(user_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/users/{}", + client.baseurl, + encode_path(&user_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out new file mode 100644 index 0000000..3baef7b --- /dev/null +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -0,0 +1,12852 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; +pub use progenitor_client::{ByteStream, Error, ResponseValue}; +pub mod types { + use serde::{Deserialize, Serialize}; + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct BlockSize(i64); + impl std::ops::Deref for BlockSize { + type Target = i64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl std::convert::TryFrom for BlockSize { + type Error = &'static str; + fn try_from(value: i64) -> Result { + if ![512_i64, 2048_i64, 4096_i64].contains(&value) { + Err("invalid value") + } else { + Ok(Self(value)) + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ByteCount(pub u64); + impl std::ops::Deref for ByteCount { + type Target = u64; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///The type of an individual datum of a metric. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + 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 ToString for DatumType { + fn to_string(&self) -> String { + match *self { + DatumType::Bool => "bool".to_string(), + DatumType::I64 => "i64".to_string(), + DatumType::F64 => "f64".to_string(), + DatumType::String => "string".to_string(), + DatumType::Bytes => "bytes".to_string(), + DatumType::CumulativeI64 => "cumulative_i64".to_string(), + DatumType::CumulativeF64 => "cumulative_f64".to_string(), + DatumType::HistogramI64 => "histogram_i64".to_string(), + DatumType::HistogramF64 => "histogram_f64".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Digest { + #[serde(rename = "type")] + pub type_: DigestType, + pub value: String, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum DigestType { + #[serde(rename = "sha256")] + Sha256, + } + + impl ToString for DigestType { + fn to_string(&self) -> String { + match *self { + DigestType::Sha256 => "sha256".to_string(), + } + } + } + + ///Client view of an [`Disk`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Disk { + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + pub device_path: String, + ///unique, immutable, system-controlled identifier for each resource + pub id: uuid::Uuid, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub image_id: Option, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + pub project_id: uuid::Uuid, + pub size: ByteCount, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub snapshot_id: Option, + pub state: DiskState, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskCreate { + pub description: String, + ///initial source for this disk + pub disk_source: DiskSource, + pub name: Name, + ///total size of the Disk in bytes + pub size: ByteCount, + } + + ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be + /// attached or detached to an instance + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskIdentifier { + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct DiskResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Different sources for a disk + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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 }, + } + + ///State of a Disk (primarily: attached or not) + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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, + } + + ///Error information from a response. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Error { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub error_code: Option, + pub message: String, + pub request_id: String, + } + + ///The name and type information for a field of a timeseries schema. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FieldSchema { + pub name: String, + pub source: FieldSource, + pub ty: FieldType, + } + + ///The source from which a field is derived, the target or metric. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum FieldSource { + #[serde(rename = "target")] + Target, + #[serde(rename = "metric")] + Metric, + } + + impl ToString for FieldSource { + fn to_string(&self) -> String { + match *self { + FieldSource::Target => "target".to_string(), + FieldSource::Metric => "metric".to_string(), + } + } + } + + ///The `FieldType` identifies the data type of a target or metric field. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + 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 ToString for FieldType { + fn to_string(&self) -> String { + match *self { + FieldType::String => "string".to_string(), + FieldType::I64 => "i64".to_string(), + FieldType::IpAddr => "ip_addr".to_string(), + FieldType::Uuid => "uuid".to_string(), + FieldType::Bool => "bool".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum FleetRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for FleetRoles { + fn to_string(&self) -> String { + match *self { + FleetRoles::Admin => "admin".to_string(), + FleetRoles::Collaborator => "collaborator".to_string(), + FleetRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FleetRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct FleetRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: FleetRoles, + } + + ///Client view of global Images + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalImage { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "Option::is_none")] + pub digest: Option, + ///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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + ///Version of this, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct GlobalImageResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum IdSortMode { + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ToString for IdSortMode { + fn to_string(&self) -> String { + match *self { + IdSortMode::IdAscending => "id_ascending".to_string(), + } + } + } + + ///Describes what kind of identity is described by an id + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum IdentityType { + #[serde(rename = "silo_user")] + SiloUser, + } + + impl ToString for IdentityType { + fn to_string(&self) -> String { + match *self { + IdentityType::SiloUser => "silo_user".to_string(), + } + } + } + + ///Client view of project Images + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Image { + ///size of blocks in bytes + pub block_size: ByteCount, + ///human-readable free-form text about a resource + pub description: String, + ///Hash of the image contents, if applicable + #[serde(default, skip_serializing_if = "Option::is_none")] + pub digest: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///URL source of this image, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + ///Version of this, if any + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + } + + ///Create-time parameters for an + /// [`Image`](omicron_common::api::external::Image) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ImageCreate { + ///block size in bytes + pub block_size: BlockSize, + pub description: String, + pub name: Name, + ///The source of the image's contents. + pub source: ImageSource, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ImageResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///The source of the underlying image. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "src")] + pub enum ImageSource { + #[serde(rename = "url")] + Url(String), + #[serde(rename = "snapshot")] + Snapshot(uuid::Uuid), + } + + ///Client view of an [`Instance`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Instance { + ///human-readable free-form text about a resource + pub description: String, + ///RFC1035-compliant hostname for the Instance. + pub hostname: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + pub time_run_state_updated: chrono::DateTime, + } + + ///The number of CPUs in an Instance + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceCpuCount(pub u16); + impl std::ops::Deref for InstanceCpuCount { + type Target = u16; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceCreate { + pub description: String, + ///The disks to be created or attached for this instance. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub disks: Vec, + pub hostname: String, + pub memory: ByteCount, + pub name: Name, + pub ncpus: InstanceCpuCount, + ///The network interfaces to be created for this instance. + #[serde(default = "instance_create_network_interfaces")] + pub network_interfaces: InstanceNetworkInterfaceAttachment, + ///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: String, + } + + fn instance_create_network_interfaces() -> InstanceNetworkInterfaceAttachment { + InstanceNetworkInterfaceAttachment::Default + } + + ///Describe the instance's disks at creation time + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type")] + pub enum InstanceDiskAttachment { + ///During instance creation, create and attach disks + #[serde(rename = "create")] + Create { + description: 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, + }, + } + + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceMigrate { + pub dst_sled_uuid: uuid::Uuid, + } + + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "params")] + pub enum InstanceNetworkInterfaceAttachment { + ///Create one or more `NetworkInterface`s for the `Instance` + #[serde(rename = "create")] + Create(Vec), + #[serde(rename = "default")] + Default, + #[serde(rename = "none")] + None, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct InstanceResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///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 + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum InstanceState { + #[serde(rename = "creating")] + Creating, + #[serde(rename = "starting")] + Starting, + #[serde(rename = "running")] + Running, + #[serde(rename = "stopping")] + Stopping, + #[serde(rename = "stopped")] + Stopped, + #[serde(rename = "rebooting")] + Rebooting, + #[serde(rename = "migrating")] + Migrating, + #[serde(rename = "repairing")] + Repairing, + #[serde(rename = "failed")] + Failed, + #[serde(rename = "destroyed")] + Destroyed, + } + + impl ToString for InstanceState { + fn to_string(&self) -> String { + match *self { + InstanceState::Creating => "creating".to_string(), + InstanceState::Starting => "starting".to_string(), + InstanceState::Running => "running".to_string(), + InstanceState::Stopping => "stopping".to_string(), + InstanceState::Stopped => "stopped".to_string(), + InstanceState::Rebooting => "rebooting".to_string(), + InstanceState::Migrating => "migrating".to_string(), + InstanceState::Repairing => "repairing".to_string(), + InstanceState::Failed => "failed".to_string(), + InstanceState::Destroyed => "destroyed".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(untagged)] + pub enum IpNet { + V4(Ipv4Net), + V6(Ipv6Net), + } + + ///An IPv4 subnet, including prefix and subnet mask + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Ipv4Net(pub String); + impl std::ops::Deref for Ipv4Net { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///An IPv6 subnet, including prefix and subnet mask + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Ipv6Net(pub String); + impl std::ops::Deref for Ipv6Net { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct L4PortRange(pub String); + impl std::ops::Deref for L4PortRange { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct LoginParams { + pub username: String, + } + + ///A Media Access Control address, in EUI-48 format + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct MacAddr(pub String); + impl std::ops::Deref for MacAddr { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///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 '-'. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Name(pub String); + impl std::ops::Deref for Name { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///Supported set of sort modes for scanning by name or id + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum NameOrIdSortMode { + #[serde(rename = "name_ascending")] + NameAscending, + #[serde(rename = "name_descending")] + NameDescending, + #[serde(rename = "id_ascending")] + IdAscending, + } + + impl ToString for NameOrIdSortMode { + fn to_string(&self) -> String { + match *self { + NameOrIdSortMode::NameAscending => "name_ascending".to_string(), + NameOrIdSortMode::NameDescending => "name_descending".to_string(), + NameOrIdSortMode::IdAscending => "id_ascending".to_string(), + } + } + } + + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum NameSortMode { + #[serde(rename = "name_ascending")] + NameAscending, + } + + impl ToString for NameSortMode { + fn to_string(&self) -> String { + match *self { + NameSortMode::NameAscending => "name_ascending".to_string(), + } + } + } + + ///A `NetworkInterface` represents a virtual network interface device. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterface { + ///human-readable free-form text about a resource + pub description: 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: String, + ///The MAC address assigned to this interface. + pub mac: MacAddr, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///The subnet to which the interface belongs. + pub subnet_id: uuid::Uuid, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the interface belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterfaceCreate { + pub description: String, + ///The IP address for the interface. One will be auto-assigned if not + /// provided. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ip: Option, + 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, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct NetworkInterfaceResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of an [`Organization`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Organization { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationCreate { + pub description: String, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum OrganizationRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + } + + impl ToString for OrganizationRoles { + fn to_string(&self) -> String { + match *self { + OrganizationRoles::Admin => "admin".to_string(), + OrganizationRoles::Collaborator => "collaborator".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: OrganizationRoles, + } + + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct OrganizationUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Client view of a [`Project`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Project { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectCreate { + pub description: String, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum ProjectRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for ProjectRoles { + fn to_string(&self) -> String { + match *self { + ProjectRoles::Admin => "admin".to_string(), + ProjectRoles::Collaborator => "collaborator".to_string(), + ProjectRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: ProjectRoles, + } + + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct ProjectUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Client view of an [`Rack`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Rack { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RackResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`Role`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Role { + pub description: String, + pub name: RoleName, + } + + ///Role names consist of two string components separated by dot ("."). + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RoleName(pub String); + impl std::ops::Deref for RoleName { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RoleResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "value")] + pub enum RouteDestination { + ///Route applies to traffic destined for a specific IP address + #[serde(rename = "ip")] + Ip(String), + ///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), + } + + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "type", content = "value")] + pub enum RouteTarget { + ///Forward traffic to a particular IP address. + #[serde(rename = "ip")] + Ip(String), + ///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), + } + + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRoute { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC Router to which the route belongs. + pub vpc_router_id: uuid::Uuid, + } + + ///Create-time parameters for a [`RouterRoute`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteCreateParams { + pub description: String, + pub destination: RouteDestination, + pub name: Name, + pub target: RouteTarget, + } + + ///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 + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum RouterRouteKind { + #[serde(rename = "default")] + Default, + #[serde(rename = "vpc_subnet")] + VpcSubnet, + #[serde(rename = "vpc_peering")] + VpcPeering, + #[serde(rename = "custom")] + Custom, + } + + impl ToString for RouterRouteKind { + fn to_string(&self) -> String { + match *self { + RouterRouteKind::Default => "default".to_string(), + RouterRouteKind::VpcSubnet => "vpc_subnet".to_string(), + RouterRouteKind::VpcPeering => "vpc_peering".to_string(), + RouterRouteKind::Custom => "custom".to_string(), + } + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a [`RouterRoute`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct RouterRouteUpdateParams { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + pub destination: RouteDestination, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + pub target: RouteTarget, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Saga { + pub id: uuid::Uuid, + pub state: SagaState, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "error")] + pub enum SagaErrorInfo { + #[serde(rename = "action_failed")] + ActionFailed { source_error: serde_json::Value }, + #[serde(rename = "deserialize_failed")] + DeserializeFailed { message: String }, + #[serde(rename = "injected_error")] + InjectedError, + #[serde(rename = "serialize_failed")] + SerializeFailed { message: String }, + #[serde(rename = "subsaga_create_failed")] + SubsagaCreateFailed { message: String }, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SagaResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone)] + #[serde(tag = "state")] + pub enum SagaState { + #[serde(rename = "running")] + Running, + #[serde(rename = "succeeded")] + Succeeded, + #[serde(rename = "failed")] + Failed { + error_info: SagaErrorInfo, + error_node_name: String, + }, + } + + ///Client view of currently authed user. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SessionUser { + pub id: uuid::Uuid, + } + + ///Client view of a ['Silo'] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Silo { + ///human-readable free-form text about a resource + pub description: 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, + ///unique, mutable, user-controlled identifier for each resource + pub name: Name, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloCreate { + pub description: String, + pub discoverable: bool, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum SiloRoles { + #[serde(rename = "admin")] + Admin, + #[serde(rename = "collaborator")] + Collaborator, + #[serde(rename = "viewer")] + Viewer, + } + + impl ToString for SiloRoles { + fn to_string(&self) -> String { + match *self { + SiloRoles::Admin => "admin".to_string(), + SiloRoles::Collaborator => "collaborator".to_string(), + SiloRoles::Viewer => "viewer".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloRolesPolicy { + ///Roles directly assigned on this resource + pub role_assignments: Vec, + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SiloRolesRoleAssignment { + pub identity_id: uuid::Uuid, + pub identity_type: IdentityType, + pub role_name: SiloRoles, + } + + ///Client view of an [`Sled`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Sled { + ///human-readable free-form text about a resource + pub description: 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_address: String, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SledResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a Snapshot + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Snapshot { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a + /// [`Snapshot`](omicron_common::api::external::Snapshot) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SnapshotCreate { + pub description: String, + ///The name of the disk to be snapshotted + pub disk: Name, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SnapshotResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`SshKey`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKey { + ///human-readable free-form text about a resource + pub description: 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: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKeyCreate { + pub description: String, + pub name: Name, + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` + pub public_key: String, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct SshKeyResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesName(pub String); + impl std::ops::Deref for TimeseriesName { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesSchema { + pub created: chrono::DateTime, + pub datum_type: DatumType, + pub field_schema: Vec, + pub timeseries_name: TimeseriesName, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct TimeseriesSchemaResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`User`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct User { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct UserResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Client view of a [`Vpc`] + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct Vpc { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + } + + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcCreate { + pub description: 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 = "Option::is_none")] + pub ipv6_prefix: Option, + pub name: Name, + } + + ///A single rule in a VPC firewall + #[derive(Serialize, Deserialize, Debug, Clone)] + 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: 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: Vec, + ///timestamp when this resource was created + pub time_created: chrono::DateTime, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///the VPC to which this rule belongs + pub vpc_id: uuid::Uuid, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleAction { + #[serde(rename = "allow")] + Allow, + #[serde(rename = "deny")] + Deny, + } + + impl ToString for VpcFirewallRuleAction { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleAction::Allow => "allow".to_string(), + VpcFirewallRuleAction::Deny => "deny".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleDirection { + #[serde(rename = "inbound")] + Inbound, + #[serde(rename = "outbound")] + Outbound, + } + + impl ToString for VpcFirewallRuleDirection { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleDirection::Inbound => "inbound".to_string(), + VpcFirewallRuleDirection::Outbound => "outbound".to_string(), + } + } + } + + ///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. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRuleFilter { + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub hosts: Option>, + ///If present, the destination ports this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub ports: Option>, + ///If present, the networking protocols this rule applies to. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub protocols: Option>, + } + + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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(String), + ///The rule applies to traffic from/to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + ///The protocols that may be specified in a firewall rule's filter + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleProtocol { + #[serde(rename = "TCP")] + Tcp, + #[serde(rename = "UDP")] + Udp, + #[serde(rename = "ICMP")] + Icmp, + } + + impl ToString for VpcFirewallRuleProtocol { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleProtocol::Tcp => "TCP".to_string(), + VpcFirewallRuleProtocol::Udp => "UDP".to_string(), + VpcFirewallRuleProtocol::Icmp => "ICMP".to_string(), + } + } + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcFirewallRuleStatus { + #[serde(rename = "disabled")] + Disabled, + #[serde(rename = "enabled")] + Enabled, + } + + impl ToString for VpcFirewallRuleStatus { + fn to_string(&self) -> String { + match *self { + VpcFirewallRuleStatus::Disabled => "disabled".to_string(), + VpcFirewallRuleStatus::Enabled => "enabled".to_string(), + } + } + } + + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. + #[derive(Serialize, Deserialize, Debug, Clone)] + #[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(String), + ///The rule applies to a specific IP subnet + #[serde(rename = "ip_net")] + IpNet(IpNet), + } + + ///A single rule in a VPC firewall + #[derive(Serialize, Deserialize, Debug, Clone)] + 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: 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: Vec, + } + + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRuleUpdateParams { + pub rules: Vec, + } + + ///Collection of a [`Vpc`]'s firewall rules + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcFirewallRules { + pub rules: Vec, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouter { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the router belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterCreate { + pub description: String, + pub name: Name, + } + + #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] + pub enum VpcRouterKind { + #[serde(rename = "system")] + System, + #[serde(rename = "custom")] + Custom, + } + + impl ToString for VpcRouterKind { + fn to_string(&self) -> String { + match *self { + VpcRouterKind::System => "system".to_string(), + VpcRouterKind::Custom => "custom".to_string(), + } + } + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcRouterUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnet { + ///human-readable free-form text about a resource + pub description: 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, + ///timestamp when this resource was last modified + pub time_modified: chrono::DateTime, + ///The VPC to which the subnet belongs. + pub vpc_id: uuid::Uuid, + } + + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetCreate { + pub description: 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 = "Option::is_none")] + pub ipv6_block: Option, + pub name: Name, + } + + ///A single page of results + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetResultsPage { + ///list of items on this page of results + pub items: Vec, + ///token used to fetch the next page of results (if any) + #[serde(default, skip_serializing_if = "Option::is_none")] + pub next_page: Option, + } + + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcSubnetUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } + + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) + #[derive(Serialize, Deserialize, Debug, Clone)] + pub struct VpcUpdate { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub description: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub dns_name: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub name: Option, + } +} + +#[derive(Clone)] +pub struct Client { + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, +} + +impl Client { + pub fn new(baseurl: &str) -> Self { + let dur = std::time::Duration::from_secs(15); + let client = reqwest::ClientBuilder::new() + .connect_timeout(dur) + .timeout(dur) + .build() + .unwrap(); + Self::new_with_client(baseurl, client) + } + + pub fn new_with_client(baseurl: &str, client: reqwest::Client) -> Self { + Self { + baseurl: baseurl.to_string(), + client, + } + } + + pub fn baseurl(&self) -> &String { + &self.baseurl + } + + pub fn client(&self) -> &reqwest::Client { + &self.client + } +} + +impl Client { + ///List racks in the system + /// + ///Sends a `GET` request to `/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.hardware_racks_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn hardware_racks_get(&self) -> builder::HardwareRacksGet { + builder::HardwareRacksGet::new(self) + } + + ///Fetch information about a particular rack + /// + ///Sends a `GET` request to `/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. + /// + ///```ignore + /// let response = client.hardware_racks_get_rack() + /// .rack_id(rack_id) + /// .send() + /// .await; + /// ``` + pub fn hardware_racks_get_rack(&self) -> builder::HardwareRacksGetRack { + builder::HardwareRacksGetRack::new(self) + } + + ///List sleds in the system + /// + ///Sends a `GET` request to `/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.hardware_sleds_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn hardware_sleds_get(&self) -> builder::HardwareSledsGet { + builder::HardwareSledsGet::new(self) + } + + ///Fetch information about a sled in the system + /// + ///Sends a `GET` request to `/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. + /// + ///```ignore + /// let response = client.hardware_sleds_get_sled() + /// .sled_id(sled_id) + /// .send() + /// .await; + /// ``` + pub fn hardware_sleds_get_sled(&self) -> builder::HardwareSledsGetSled { + builder::HardwareSledsGetSled::new(self) + } + + ///List global images + /// + ///Returns a list of all the global images. Global images are returned + /// sorted by creation date, with the most recent images appearing first. + /// + ///Sends a `GET` request to `/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.images_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn images_get(&self) -> builder::ImagesGet { + builder::ImagesGet::new(self) + } + + ///Create a global image + /// + ///Create a new global image. This image can then be used by any user as a + /// base for instances. + /// + ///Sends a `POST` request to `/images` + ///```ignore + /// let response = client.images_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn images_post(&self) -> builder::ImagesPost { + builder::ImagesPost::new(self) + } + + ///Get a global image + /// + ///Returns the details of a specific global image. + /// + ///Sends a `GET` request to `/images/{image_name}` + ///```ignore + /// let response = client.images_get_image() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn images_get_image(&self) -> builder::ImagesGetImage { + builder::ImagesGetImage::new(self) + } + + ///Delete a global image + /// + ///Permanently delete a global image. This operation cannot be undone. Any + /// instances using the global image will continue to run, however new + /// instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/images/{image_name}` + ///```ignore + /// let response = client.images_delete_image() + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn images_delete_image(&self) -> builder::ImagesDeleteImage { + builder::ImagesDeleteImage::new(self) + } + + ///Sends a `POST` request to `/login` + ///```ignore + /// let response = client.spoof_login() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn spoof_login(&self) -> builder::SpoofLogin { + builder::SpoofLogin::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 all organizations + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.organizations_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn organizations_get(&self) -> builder::OrganizationsGet { + builder::OrganizationsGet::new(self) + } + + ///Create a new organization + /// + ///Sends a `POST` request to `/organizations` + ///```ignore + /// let response = client.organizations_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organizations_post(&self) -> builder::OrganizationsPost { + builder::OrganizationsPost::new(self) + } + + ///Fetch a specific organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organizations_get_organization() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organizations_get_organization(&self) -> builder::OrganizationsGetOrganization { + builder::OrganizationsGetOrganization::new(self) + } + + ///Update a specific organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organizations_put_organization() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organizations_put_organization(&self) -> builder::OrganizationsPutOrganization { + builder::OrganizationsPutOrganization::new(self) + } + + ///Delete a specific organization + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organizations_delete_organization() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organizations_delete_organization(&self) -> builder::OrganizationsDeleteOrganization { + builder::OrganizationsDeleteOrganization::new(self) + } + + ///Fetch the IAM policy for this Organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// + ///```ignore + /// let response = client.organization_get_policy() + /// .organization_name(organization_name) + /// .send() + /// .await; + /// ``` + pub fn organization_get_policy(&self) -> builder::OrganizationGetPolicy { + builder::OrganizationGetPolicy::new(self) + } + + ///Update the IAM policy for this Organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organization_put_policy() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_put_policy(&self) -> builder::OrganizationPutPolicy { + builder::OrganizationPutPolicy::new(self) + } + + ///List all projects + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.organization_projects_get() + /// .organization_name(organization_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_get(&self) -> builder::OrganizationProjectsGet { + builder::OrganizationProjectsGet::new(self) + } + + ///Create a new project + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.organization_projects_post() + /// .organization_name(organization_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_post(&self) -> builder::OrganizationProjectsPost { + builder::OrganizationProjectsPost::new(self) + } + + ///Fetch a specific project + /// + ///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.organization_projects_get_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_get_project(&self) -> builder::OrganizationProjectsGetProject { + builder::OrganizationProjectsGetProject::new(self) + } + + ///Update a specific project + /// + ///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.organization_projects_put_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_put_project(&self) -> builder::OrganizationProjectsPutProject { + builder::OrganizationProjectsPutProject::new(self) + } + + ///Delete a specific project + /// + ///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.organization_projects_delete_project() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_delete_project( + &self, + ) -> builder::OrganizationProjectsDeleteProject { + builder::OrganizationProjectsDeleteProject::new(self) + } + + ///List disks in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_disks_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_disks_get(&self) -> builder::ProjectDisksGet { + builder::ProjectDisksGet::new(self) + } + + ///Create a disk in a project + /// + ///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.project_disks_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_disks_post(&self) -> builder::ProjectDisksPost { + builder::ProjectDisksPost::new(self) + } + + ///Fetch a single disk in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` ```ignore + /// let response = client.project_disks_get_disk() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + pub fn project_disks_get_disk(&self) -> builder::ProjectDisksGetDisk { + builder::ProjectDisksGetDisk::new(self) + } + + ///Delete a disk from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` ```ignore + /// let response = client.project_disks_delete_disk() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .disk_name(disk_name) + /// .send() + /// .await; + /// ``` + pub fn project_disks_delete_disk(&self) -> builder::ProjectDisksDeleteDisk { + builder::ProjectDisksDeleteDisk::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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_images_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_images_get(&self) -> builder::ProjectImagesGet { + builder::ProjectImagesGet::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.project_images_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_images_post(&self) -> builder::ProjectImagesPost { + builder::ProjectImagesPost::new(self) + } + + ///Get an image + /// + ///Get the details of a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` ```ignore + /// let response = client.project_images_get_image() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn project_images_get_image(&self) -> builder::ProjectImagesGetImage { + builder::ProjectImagesGetImage::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.project_images_delete_image() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .image_name(image_name) + /// .send() + /// .await; + /// ``` + pub fn project_images_delete_image(&self) -> builder::ProjectImagesDeleteImage { + builder::ProjectImagesDeleteImage::new(self) + } + + ///List instances in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_instances_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_instances_get(&self) -> builder::ProjectInstancesGet { + builder::ProjectInstancesGet::new(self) + } + + ///Create an instance in a project + /// + ///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.project_instances_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_instances_post(&self) -> builder::ProjectInstancesPost { + builder::ProjectInstancesPost::new(self) + } + + ///Get an instance in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` ```ignore + /// let response = client.project_instances_get_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn project_instances_get_instance(&self) -> builder::ProjectInstancesGetInstance { + builder::ProjectInstancesGetInstance::new(self) + } + + ///Delete an instance from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` ```ignore + /// let response = client.project_instances_delete_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn project_instances_delete_instance(&self) -> builder::ProjectInstancesDeleteInstance { + builder::ProjectInstancesDeleteInstance::new(self) + } + + ///List disks attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.instance_disks_get() + /// .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_disks_get(&self) -> builder::InstanceDisksGet { + builder::InstanceDisksGet::new(self) + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` ```ignore + /// let response = client.instance_disks_attach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disks_attach(&self) -> builder::InstanceDisksAttach { + builder::InstanceDisksAttach::new(self) + } + + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` ```ignore + /// let response = client.instance_disks_detach() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_disks_detach(&self) -> builder::InstanceDisksDetach { + builder::InstanceDisksDetach::new(self) + } + + ///Migrate an instance to a different propolis-server, possibly on a + /// different sled + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` ```ignore + /// let response = client.project_instances_migrate_instance() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_instances_migrate_instance(&self) -> builder::ProjectInstancesMigrateInstance { + builder::ProjectInstancesMigrateInstance::new(self) + } + + ///List network interfaces attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.instance_network_interfaces_get() + /// .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_interfaces_get(&self) -> builder::InstanceNetworkInterfacesGet { + builder::InstanceNetworkInterfacesGet::new(self) + } + + ///Create a network interface for an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` ```ignore + /// let response = client.instance_network_interfaces_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interfaces_post(&self) -> builder::InstanceNetworkInterfacesPost { + builder::InstanceNetworkInterfacesPost::new(self) + } + + ///Get an interface attached to an instance + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` ```ignore + /// let response = client.instance_network_interfaces_get_interface() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interfaces_get_interface( + &self, + ) -> builder::InstanceNetworkInterfacesGetInterface { + builder::InstanceNetworkInterfacesGetInterface::new(self) + } + + ///Detach a network interface from an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` ```ignore + /// let response = client.instance_network_interfaces_delete_interface() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .interface_name(interface_name) + /// .send() + /// .await; + /// ``` + pub fn instance_network_interfaces_delete_interface( + &self, + ) -> builder::InstanceNetworkInterfacesDeleteInterface { + builder::InstanceNetworkInterfacesDeleteInterface::new(self) + } + + ///Reboot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` ```ignore + /// let response = client.project_instances_instance_reboot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn project_instances_instance_reboot(&self) -> builder::ProjectInstancesInstanceReboot { + builder::ProjectInstancesInstanceReboot::new(self) + } + + ///Boot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` ```ignore + /// let response = client.project_instances_instance_start() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn project_instances_instance_start(&self) -> builder::ProjectInstancesInstanceStart { + builder::ProjectInstancesInstanceStart::new(self) + } + + ///Halt an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` ```ignore + /// let response = client.project_instances_instance_stop() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .instance_name(instance_name) + /// .send() + /// .await; + /// ``` + pub fn project_instances_instance_stop(&self) -> builder::ProjectInstancesInstanceStop { + builder::ProjectInstancesInstanceStop::new(self) + } + + ///Fetch the IAM policy for this Project + /// + ///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.organization_projects_get_project_policy() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_get_project_policy( + &self, + ) -> builder::OrganizationProjectsGetProjectPolicy { + builder::OrganizationProjectsGetProjectPolicy::new(self) + } + + ///Update the IAM policy for this Project + /// + ///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.organization_projects_put_project_policy() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn organization_projects_put_project_policy( + &self, + ) -> builder::OrganizationProjectsPutProjectPolicy { + builder::OrganizationProjectsPutProjectPolicy::new(self) + } + + ///List snapshots in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_snapshots_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_snapshots_get(&self) -> builder::ProjectSnapshotsGet { + builder::ProjectSnapshotsGet::new(self) + } + + ///Create a snapshot of 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.project_snapshots_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_snapshots_post(&self) -> builder::ProjectSnapshotsPost { + builder::ProjectSnapshotsPost::new(self) + } + + ///Get a snapshot in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` ```ignore + /// let response = client.project_snapshots_get_snapshot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + pub fn project_snapshots_get_snapshot(&self) -> builder::ProjectSnapshotsGetSnapshot { + builder::ProjectSnapshotsGetSnapshot::new(self) + } + + ///Delete a snapshot from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` ```ignore + /// let response = client.project_snapshots_delete_snapshot() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .snapshot_name(snapshot_name) + /// .send() + /// .await; + /// ``` + pub fn project_snapshots_delete_snapshot(&self) -> builder::ProjectSnapshotsDeleteSnapshot { + builder::ProjectSnapshotsDeleteSnapshot::new(self) + } + + ///List VPCs in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.project_vpcs_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn project_vpcs_get(&self) -> builder::ProjectVpcsGet { + builder::ProjectVpcsGet::new(self) + } + + ///Create a VPC in a project + /// + ///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.project_vpcs_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_vpcs_post(&self) -> builder::ProjectVpcsPost { + builder::ProjectVpcsPost::new(self) + } + + ///Get a VPC in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_get_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn project_vpcs_get_vpc(&self) -> builder::ProjectVpcsGetVpc { + builder::ProjectVpcsGetVpc::new(self) + } + + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_put_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn project_vpcs_put_vpc(&self) -> builder::ProjectVpcsPutVpc { + builder::ProjectVpcsPutVpc::new(self) + } + + ///Delete a vpc from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` ```ignore + /// let response = client.project_vpcs_delete_vpc() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn project_vpcs_delete_vpc(&self) -> builder::ProjectVpcsDeleteVpc { + builder::ProjectVpcsDeleteVpc::new(self) + } + + ///List firewall rules for a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` ```ignore + /// let response = client.vpc_firewall_rules_get() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_firewall_rules_get(&self) -> builder::VpcFirewallRulesGet { + builder::VpcFirewallRulesGet::new(self) + } + + ///Replace the firewall rules for a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` ```ignore + /// let response = client.vpc_firewall_rules_put() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_firewall_rules_put(&self) -> builder::VpcFirewallRulesPut { + builder::VpcFirewallRulesPut::new(self) + } + + ///List VPC Custom and System 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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.vpc_routers_get() + /// .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_routers_get(&self) -> builder::VpcRoutersGet { + builder::VpcRoutersGet::new(self) + } + + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` ```ignore + /// let response = client.vpc_routers_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_routers_post(&self) -> builder::VpcRoutersPost { + builder::VpcRoutersPost::new(self) + } + + ///Get a VPC Router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_get_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_routers_get_router(&self) -> builder::VpcRoutersGetRouter { + builder::VpcRoutersGetRouter::new(self) + } + + ///Update a VPC Router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_put_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_routers_put_router(&self) -> builder::VpcRoutersPutRouter { + builder::VpcRoutersPutRouter::new(self) + } + + ///Delete a router from its VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` ```ignore + /// let response = client.vpc_routers_delete_router() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_routers_delete_router(&self) -> builder::VpcRoutersDeleteRouter { + builder::VpcRoutersDeleteRouter::new(self) + } + + ///List a Router's routes + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.routers_routes_get() + /// .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 routers_routes_get(&self) -> builder::RoutersRoutesGet { + builder::RoutersRoutesGet::new(self) + } + + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` ```ignore + /// let response = client.routers_routes_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn routers_routes_post(&self) -> builder::RoutersRoutesPost { + builder::RoutersRoutesPost::new(self) + } + + ///Get a VPC Router 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.routers_routes_get_route() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + pub fn routers_routes_get_route(&self) -> builder::RoutersRoutesGetRoute { + builder::RoutersRoutesGetRoute::new(self) + } + + ///Update a Router 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.routers_routes_put_route() + /// .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 routers_routes_put_route(&self) -> builder::RoutersRoutesPutRoute { + builder::RoutersRoutesPutRoute::new(self) + } + + ///Delete a route from its router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` ```ignore + /// let response = client.routers_routes_delete_route() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .router_name(router_name) + /// .route_name(route_name) + /// .send() + /// .await; + /// ``` + pub fn routers_routes_delete_route(&self) -> builder::RoutersRoutesDeleteRoute { + builder::RoutersRoutesDeleteRoute::new(self) + } + + ///List subnets in a VPC + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.vpc_subnets_get() + /// .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_subnets_get(&self) -> builder::VpcSubnetsGet { + builder::VpcSubnetsGet::new(self) + } + + ///Create a subnet in a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` ```ignore + /// let response = client.vpc_subnets_post() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnets_post(&self) -> builder::VpcSubnetsPost { + builder::VpcSubnetsPost::new(self) + } + + ///Get subnet in a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_get_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnets_get_subnet(&self) -> builder::VpcSubnetsGetSubnet { + builder::VpcSubnetsGetSubnet::new(self) + } + + ///Update a VPC Subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_put_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnets_put_subnet(&self) -> builder::VpcSubnetsPutSubnet { + builder::VpcSubnetsPutSubnet::new(self) + } + + ///Delete a subnet from a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` ```ignore + /// let response = client.vpc_subnets_delete_subnet() + /// .organization_name(organization_name) + /// .project_name(project_name) + /// .vpc_name(vpc_name) + /// .subnet_name(subnet_name) + /// .send() + /// .await; + /// ``` + pub fn vpc_subnets_delete_subnet(&self) -> builder::VpcSubnetsDeleteSubnet { + builder::VpcSubnetsDeleteSubnet::new(self) + } + + ///List network interfaces in a VPC subnet + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.subnet_network_interfaces_get() + /// .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 subnet_network_interfaces_get(&self) -> builder::SubnetNetworkInterfacesGet { + builder::SubnetNetworkInterfacesGet::new(self) + } + + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/policy` + ///```ignore + /// let response = client.policy_get() + /// .send() + /// .await; + /// ``` + pub fn policy_get(&self) -> builder::PolicyGet { + builder::PolicyGet::new(self) + } + + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/policy` + ///```ignore + /// let response = client.policy_put() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn policy_put(&self) -> builder::PolicyPut { + builder::PolicyPut::new(self) + } + + ///List the 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 retreive the + /// subsequent page + /// + ///```ignore + /// let response = client.roles_get() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + pub fn roles_get(&self) -> builder::RolesGet { + builder::RolesGet::new(self) + } + + ///Fetch a specific 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.roles_get_role() + /// .role_name(role_name) + /// .send() + /// .await; + /// ``` + pub fn roles_get_role(&self) -> builder::RolesGetRole { + builder::RolesGetRole::new(self) + } + + ///List all sagas (for debugging) + /// + ///Sends a `GET` request to `/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.sagas_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sagas_get(&self) -> builder::SagasGet { + builder::SagasGet::new(self) + } + + ///Fetch information about a single saga (for debugging) + /// + ///Sends a `GET` request to `/sagas/{saga_id}` + ///```ignore + /// let response = client.sagas_get_saga() + /// .saga_id(saga_id) + /// .send() + /// .await; + /// ``` + pub fn sagas_get_saga(&self) -> builder::SagasGetSaga { + builder::SagasGetSaga::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) + } + + ///List the current user's SSH public keys + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.sshkeys_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn sshkeys_get(&self) -> builder::SshkeysGet { + builder::SshkeysGet::new(self) + } + + ///Create a new SSH public key for the current user + /// + ///Sends a `POST` request to `/session/me/sshkeys` + ///```ignore + /// let response = client.sshkeys_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn sshkeys_post(&self) -> builder::SshkeysPost { + builder::SshkeysPost::new(self) + } + + ///Get (by name) an SSH public key belonging to the current user + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` + ///```ignore + /// let response = client.sshkeys_get_key() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + pub fn sshkeys_get_key(&self) -> builder::SshkeysGetKey { + builder::SshkeysGetKey::new(self) + } + + ///Delete (by name) an SSH public key belonging to the current user + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` + ///```ignore + /// let response = client.sshkeys_delete_key() + /// .ssh_key_name(ssh_key_name) + /// .send() + /// .await; + /// ``` + pub fn sshkeys_delete_key(&self) -> builder::SshkeysDeleteKey { + builder::SshkeysDeleteKey::new(self) + } + + ///Sends a `GET` request to `/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.silos_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn silos_get(&self) -> builder::SilosGet { + builder::SilosGet::new(self) + } + + ///Create a new silo + /// + ///Sends a `POST` request to `/silos` + ///```ignore + /// let response = client.silos_post() + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn silos_post(&self) -> builder::SilosPost { + builder::SilosPost::new(self) + } + + ///Fetch a specific silo + /// + ///Sends a `GET` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_get_silo() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silos_get_silo(&self) -> builder::SilosGetSilo { + builder::SilosGetSilo::new(self) + } + + ///Delete a specific silo + /// + ///Sends a `DELETE` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_delete_silo() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silos_delete_silo(&self) -> builder::SilosDeleteSilo { + builder::SilosDeleteSilo::new(self) + } + + ///Fetch the IAM policy for this Silo + /// + ///Sends a `GET` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// + ///```ignore + /// let response = client.silos_get_silo_policy() + /// .silo_name(silo_name) + /// .send() + /// .await; + /// ``` + pub fn silos_get_silo_policy(&self) -> builder::SilosGetSiloPolicy { + builder::SilosGetSiloPolicy::new(self) + } + + ///Update the IAM policy for this Silo + /// + ///Sends a `PUT` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` + /// + ///```ignore + /// let response = client.silos_put_silo_policy() + /// .silo_name(silo_name) + /// .body(body) + /// .send() + /// .await; + /// ``` + pub fn silos_put_silo_policy(&self) -> builder::SilosPutSiloPolicy { + builder::SilosPutSiloPolicy::new(self) + } + + ///List all 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 retreive 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) + } + + ///Refresh update metadata + /// + ///Sends a `POST` request to `/updates/refresh` + ///```ignore + /// let response = client.updates_refresh() + /// .send() + /// .await; + /// ``` + pub fn updates_refresh(&self) -> builder::UpdatesRefresh { + builder::UpdatesRefresh::new(self) + } + + ///List the built-in system 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 retreive the + /// subsequent page + /// - `sort_by` + /// + ///```ignore + /// let response = client.users_get() + /// .limit(limit) + /// .page_token(page_token) + /// .sort_by(sort_by) + /// .send() + /// .await; + /// ``` + pub fn users_get(&self) -> builder::UsersGet { + builder::UsersGet::new(self) + } + + ///Fetch a specific built-in system user + /// + ///Sends a `GET` request to `/users/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. + /// + ///```ignore + /// let response = client.users_get_user() + /// .user_name(user_name) + /// .send() + /// .await; + /// ``` + pub fn users_get_user(&self) -> builder::UsersGetUser { + builder::UsersGetUser::new(self) + } +} + +pub mod builder { + #[allow(unused_imports)] + use super::encode_path; + use super::types; + #[allow(unused_imports)] + use super::{ByteStream, Error, ResponseValue}; + ///Builder for [`Client::hardware_racks_get`] + /// + ///[`Client::hardware_racks_get`]: super::Client::hardware_racks_get + #[derive(Clone)] + pub struct HardwareRacksGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> HardwareRacksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/racks` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/hardware/racks", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/hardware/racks` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::hardware_racks_get_rack`] + /// + ///[`Client::hardware_racks_get_rack`]: super::Client::hardware_racks_get_rack + #[derive(Clone)] + pub struct HardwareRacksGetRack<'a> { + client: &'a super::Client, + rack_id: Option, + } + + impl<'a> HardwareRacksGetRack<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + rack_id: None, + } + } + + pub fn rack_id(mut self, value: uuid::Uuid) -> Self { + self.rack_id = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/racks/{rack_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, rack_id } = self; + let (rack_id,) = match (rack_id,) { + (Some(rack_id),) => (rack_id,), + (rack_id,) => { + let mut missing = Vec::new(); + if rack_id.is_none() { + missing.push(stringify!(rack_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/hardware/racks/{}", + client.baseurl, + encode_path(&rack_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::hardware_sleds_get`] + /// + ///[`Client::hardware_sleds_get`]: super::Client::hardware_sleds_get + #[derive(Clone)] + pub struct HardwareSledsGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> HardwareSledsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/sleds` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/hardware/sleds", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/hardware/sleds` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::hardware_sleds_get_sled`] + /// + ///[`Client::hardware_sleds_get_sled`]: super::Client::hardware_sleds_get_sled + #[derive(Clone)] + pub struct HardwareSledsGetSled<'a> { + client: &'a super::Client, + sled_id: Option, + } + + impl<'a> HardwareSledsGetSled<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + sled_id: None, + } + } + + pub fn sled_id(mut self, value: uuid::Uuid) -> Self { + self.sled_id = Some(value); + self + } + + ///Sends a `GET` request to `/hardware/sleds/{sled_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, sled_id } = self; + let (sled_id,) = match (sled_id,) { + (Some(sled_id),) => (sled_id,), + (sled_id,) => { + let mut missing = Vec::new(); + if sled_id.is_none() { + missing.push(stringify!(sled_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/hardware/sleds/{}", + client.baseurl, + encode_path(&sled_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::images_get`] + /// + ///[`Client::images_get`]: super::Client::images_get + #[derive(Clone)] + pub struct ImagesGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ImagesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/images` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/images", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/images` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::images_post`] + /// + ///[`Client::images_post`]: super::Client::images_post + #[derive(Clone)] + pub struct ImagesPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> ImagesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::ImageCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/images` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/images", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::images_get_image`] + /// + ///[`Client::images_get_image`]: super::Client::images_get_image + #[derive(Clone)] + pub struct ImagesGetImage<'a> { + client: &'a super::Client, + image_name: Option, + } + + impl<'a> ImagesGetImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: None, + } + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + self + } + + ///Sends a `GET` request to `/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let (image_name,) = match (image_name,) { + (Some(image_name),) => (image_name,), + (image_name,) => { + let mut missing = Vec::new(); + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::images_delete_image`] + /// + ///[`Client::images_delete_image`]: super::Client::images_delete_image + #[derive(Clone)] + pub struct ImagesDeleteImage<'a> { + client: &'a super::Client, + image_name: Option, + } + + impl<'a> ImagesDeleteImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + image_name: None, + } + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + self + } + + ///Sends a `DELETE` request to `/images/{image_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, image_name } = self; + let (image_name,) = match (image_name,) { + (Some(image_name),) => (image_name,), + (image_name,) => { + let mut missing = Vec::new(); + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/images/{}", + client.baseurl, + encode_path(&image_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::spoof_login`] + /// + ///[`Client::spoof_login`]: super::Client::spoof_login + #[derive(Clone)] + pub struct SpoofLogin<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SpoofLogin<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::LoginParams) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/login` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/login", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`Client::logout`] + /// + ///[`Client::logout`]: super::Client::logout + #[derive(Clone)] + pub struct Logout<'a> { + client: &'a super::Client, + } + + impl<'a> Logout<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200..=299 => Ok(ResponseValue::stream(response)), + _ => Err(Error::ErrorResponse(ResponseValue::stream(response))), + } + } + } + + ///Builder for [`Client::organizations_get`] + /// + ///[`Client::organizations_get`]: super::Client::organizations_get + #[derive(Clone)] + pub struct OrganizationsGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> OrganizationsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/organizations` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/organizations", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::organizations_post`] + /// + ///[`Client::organizations_post`]: super::Client::organizations_post + #[derive(Clone)] + pub struct OrganizationsPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> OrganizationsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::OrganizationCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/organizations` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/organizations", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::organizations_get_organization`] + /// + ///[`Client::organizations_get_organization`]: super::Client::organizations_get_organization + #[derive(Clone)] + pub struct OrganizationsGetOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationsGetOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organizations_put_organization`] + /// + ///[`Client::organizations_put_organization`]: super::Client::organizations_put_organization + #[derive(Clone)] + pub struct OrganizationsPutOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationsPutOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::OrganizationUpdate) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::organizations_delete_organization`] + /// + ///[`Client::organizations_delete_organization`]: super::Client::organizations_delete_organization + #[derive(Clone)] + pub struct OrganizationsDeleteOrganization<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationsDeleteOrganization<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_get_policy`] + /// + ///[`Client::organization_get_policy`]: super::Client::organization_get_policy + #[derive(Clone)] + pub struct OrganizationGetPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + } + + impl<'a> OrganizationGetPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_put_policy`] + /// + ///[`Client::organization_put_policy`]: super::Client::organization_put_policy + #[derive(Clone)] + pub struct OrganizationPutPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationPutPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::OrganizationRolesPolicy) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_projects_get`] + /// + ///[`Client::organization_projects_get`]: super::Client::organization_projects_get + #[derive(Clone)] + pub struct OrganizationProjectsGet<'a> { + client: &'a super::Client, + organization_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> OrganizationProjectsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + 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,) = match (organization_name,) { + (Some(organization_name),) => (organization_name,), + (organization_name,) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::organization_projects_post`] + /// + ///[`Client::organization_projects_post`]: super::Client::organization_projects_post + #[derive(Clone)] + pub struct OrganizationProjectsPost<'a> { + client: &'a super::Client, + organization_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectCreate) -> Self { + self.body = Some(value); + 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, body) = match (organization_name, body) { + (Some(organization_name), Some(body)) => (organization_name, body), + (organization_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects", + client.baseurl, + encode_path(&organization_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_projects_get_project`] + /// + ///[`Client::organization_projects_get_project`]: super::Client::organization_projects_get_project + #[derive(Clone)] + pub struct OrganizationProjectsGetProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsGetProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_projects_put_project`] + /// + ///[`Client::organization_projects_put_project`]: super::Client::organization_projects_put_project + #[derive(Clone)] + pub struct OrganizationProjectsPutProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPutProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectUpdate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_projects_delete_project`] + /// + ///[`Client::organization_projects_delete_project`]: super::Client::organization_projects_delete_project + #[derive(Clone)] + pub struct OrganizationProjectsDeleteProject<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsDeleteProject<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_get`] + /// + ///[`Client::project_disks_get`]: super::Client::project_disks_get + #[derive(Clone)] + pub struct ProjectDisksGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectDisksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_disks_post`] + /// + ///[`Client::project_disks_post`]: super::Client::project_disks_post + #[derive(Clone)] + pub struct ProjectDisksPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectDisksPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/disks", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_get_disk`] + /// + ///[`Client::project_disks_get_disk`]: super::Client::project_disks_get_disk + #[derive(Clone)] + pub struct ProjectDisksGetDisk<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + disk_name: Option, + } + + impl<'a> ProjectDisksGetDisk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + disk_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn disk_name(mut self, value: types::Name) -> Self { + self.disk_name = Some(value); + 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, project_name, disk_name) = + match (organization_name, project_name, disk_name) { + (Some(organization_name), Some(project_name), Some(disk_name)) => { + (organization_name, project_name, disk_name) + } + (organization_name, project_name, disk_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if disk_name.is_none() { + missing.push(stringify!(disk_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_disks_delete_disk`] + /// + ///[`Client::project_disks_delete_disk`]: super::Client::project_disks_delete_disk + #[derive(Clone)] + pub struct ProjectDisksDeleteDisk<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + disk_name: Option, + } + + impl<'a> ProjectDisksDeleteDisk<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + disk_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn disk_name(mut self, value: types::Name) -> Self { + self.disk_name = Some(value); + 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, project_name, disk_name) = + match (organization_name, project_name, disk_name) { + (Some(organization_name), Some(project_name), Some(disk_name)) => { + (organization_name, project_name, disk_name) + } + (organization_name, project_name, disk_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if disk_name.is_none() { + missing.push(stringify!(disk_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_images_get`] + /// + ///[`Client::project_images_get`]: super::Client::project_images_get + #[derive(Clone)] + pub struct ProjectImagesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectImagesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_images_post`] + /// + ///[`Client::project_images_post`]: super::Client::project_images_post + #[derive(Clone)] + pub struct ProjectImagesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectImagesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ImageCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/images", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_images_get_image`] + /// + ///[`Client::project_images_get_image`]: super::Client::project_images_get_image + #[derive(Clone)] + pub struct ProjectImagesGetImage<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + image_name: Option, + } + + impl<'a> ProjectImagesGetImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + image_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + 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, project_name, image_name) = + match (organization_name, project_name, image_name) { + (Some(organization_name), Some(project_name), Some(image_name)) => { + (organization_name, project_name, image_name) + } + (organization_name, project_name, image_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_images_delete_image`] + /// + ///[`Client::project_images_delete_image`]: super::Client::project_images_delete_image + #[derive(Clone)] + pub struct ProjectImagesDeleteImage<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + image_name: Option, + } + + impl<'a> ProjectImagesDeleteImage<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + image_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn image_name(mut self, value: types::Name) -> Self { + self.image_name = Some(value); + 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, project_name, image_name) = + match (organization_name, project_name, image_name) { + (Some(organization_name), Some(project_name), Some(image_name)) => { + (organization_name, project_name, image_name) + } + (organization_name, project_name, image_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if image_name.is_none() { + missing.push(stringify!(image_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_get`] + /// + ///[`Client::project_instances_get`]: super::Client::project_instances_get + #[derive(Clone)] + pub struct ProjectInstancesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectInstancesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_instances_post`] + /// + ///[`Client::project_instances_post`]: super::Client::project_instances_post + #[derive(Clone)] + pub struct ProjectInstancesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectInstancesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::InstanceCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/instances", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_get_instance`] + /// + ///[`Client::project_instances_get_instance`]: super::Client::project_instances_get_instance + #[derive(Clone)] + pub struct ProjectInstancesGetInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesGetInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_instances_delete_instance`] + /// + ///[`Client::project_instances_delete_instance`]: super::Client::project_instances_delete_instance + #[derive(Clone)] + pub struct ProjectInstancesDeleteInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesDeleteInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_get`] + /// + ///[`Client::instance_disks_get`]: super::Client::instance_disks_get + #[derive(Clone)] + pub struct InstanceDisksGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> InstanceDisksGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::instance_disks_attach`] + /// + ///[`Client::instance_disks_attach`]: super::Client::instance_disks_attach + #[derive(Clone)] + pub struct InstanceDisksAttach<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceDisksAttach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskIdentifier) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_disks_detach`] + /// + ///[`Client::instance_disks_detach`]: super::Client::instance_disks_detach + #[derive(Clone)] + pub struct InstanceDisksDetach<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceDisksDetach<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::DiskIdentifier) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_migrate_instance`] + /// + ///[`Client::project_instances_migrate_instance`]: super::Client::project_instances_migrate_instance + #[derive(Clone)] + pub struct ProjectInstancesMigrateInstance<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> ProjectInstancesMigrateInstance<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::InstanceMigrate) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_interfaces_get`] + /// + ///[`Client::instance_network_interfaces_get`]: super::Client::instance_network_interfaces_get + #[derive(Clone)] + pub struct InstanceNetworkInterfacesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> InstanceNetworkInterfacesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::instance_network_interfaces_post`] + /// + ///[`Client::instance_network_interfaces_post`]: super::Client::instance_network_interfaces_post + #[derive(Clone)] + pub struct InstanceNetworkInterfacesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + body: Option, + } + + impl<'a> InstanceNetworkInterfacesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn body(mut self, value: types::NetworkInterfaceCreate) -> Self { + self.body = Some(value); + 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, project_name, instance_name, body) = + match (organization_name, project_name, instance_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(body), + ) => (organization_name, project_name, instance_name, body), + (organization_name, project_name, instance_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_interfaces_get_interface`] + /// + ///[`Client::instance_network_interfaces_get_interface`]: super::Client::instance_network_interfaces_get_interface + #[derive(Clone)] + pub struct InstanceNetworkInterfacesGetInterface<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + interface_name: Option, + } + + impl<'a> InstanceNetworkInterfacesGetInterface<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + interface_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn interface_name(mut self, value: types::Name) -> Self { + self.interface_name = Some(value); + 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, project_name, instance_name, interface_name) = match ( + organization_name, + project_name, + instance_name, + interface_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(interface_name), + ) => ( + organization_name, + project_name, + instance_name, + interface_name, + ), + (organization_name, project_name, instance_name, interface_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if interface_name.is_none() { + missing.push(stringify!(interface_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_interfaces_delete_interface`] + /// + ///[`Client::instance_network_interfaces_delete_interface`]: super::Client::instance_network_interfaces_delete_interface + #[derive(Clone)] + pub struct InstanceNetworkInterfacesDeleteInterface<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + interface_name: Option, + } + + impl<'a> InstanceNetworkInterfacesDeleteInterface<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + interface_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + self + } + + pub fn interface_name(mut self, value: types::Name) -> Self { + self.interface_name = Some(value); + 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, project_name, instance_name, interface_name) = match ( + organization_name, + project_name, + instance_name, + interface_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(instance_name), + Some(interface_name), + ) => ( + organization_name, + project_name, + instance_name, + interface_name, + ), + (organization_name, project_name, instance_name, interface_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + if interface_name.is_none() { + missing.push(stringify!(interface_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_instance_reboot`] + /// + ///[`Client::project_instances_instance_reboot`]: super::Client::project_instances_instance_reboot + #[derive(Clone)] + pub struct ProjectInstancesInstanceReboot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceReboot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_instance_start`] + /// + ///[`Client::project_instances_instance_start`]: super::Client::project_instances_instance_start + #[derive(Clone)] + pub struct ProjectInstancesInstanceStart<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceStart<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_instances_instance_stop`] + /// + ///[`Client::project_instances_instance_stop`]: super::Client::project_instances_instance_stop + #[derive(Clone)] + pub struct ProjectInstancesInstanceStop<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + instance_name: Option, + } + + impl<'a> ProjectInstancesInstanceStop<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + instance_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn instance_name(mut self, value: types::Name) -> Self { + self.instance_name = Some(value); + 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, project_name, instance_name) = + match (organization_name, project_name, instance_name) { + (Some(organization_name), Some(project_name), Some(instance_name)) => { + (organization_name, project_name, instance_name) + } + (organization_name, project_name, instance_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if instance_name.is_none() { + missing.push(stringify!(instance_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_projects_get_project_policy`] + /// + ///[`Client::organization_projects_get_project_policy`]: super::Client::organization_projects_get_project_policy + #[derive(Clone)] + pub struct OrganizationProjectsGetProjectPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + } + + impl<'a> OrganizationProjectsGetProjectPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_projects_put_project_policy`] + /// + ///[`Client::organization_projects_put_project_policy`]: super::Client::organization_projects_put_project_policy + #[derive(Clone)] + pub struct OrganizationProjectsPutProjectPolicy<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> OrganizationProjectsPutProjectPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::ProjectRolesPolicy) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/policy", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_snapshots_get`] + /// + ///[`Client::project_snapshots_get`]: super::Client::project_snapshots_get + #[derive(Clone)] + pub struct ProjectSnapshotsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectSnapshotsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_snapshots_post`] + /// + ///[`Client::project_snapshots_post`]: super::Client::project_snapshots_post + #[derive(Clone)] + pub struct ProjectSnapshotsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectSnapshotsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::SnapshotCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/snapshots", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_snapshots_get_snapshot`] + /// + ///[`Client::project_snapshots_get_snapshot`]: super::Client::project_snapshots_get_snapshot + #[derive(Clone)] + pub struct ProjectSnapshotsGetSnapshot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + snapshot_name: Option, + } + + impl<'a> ProjectSnapshotsGetSnapshot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + snapshot_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn snapshot_name(mut self, value: types::Name) -> Self { + self.snapshot_name = Some(value); + 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, project_name, snapshot_name) = + match (organization_name, project_name, snapshot_name) { + (Some(organization_name), Some(project_name), Some(snapshot_name)) => { + (organization_name, project_name, snapshot_name) + } + (organization_name, project_name, snapshot_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if snapshot_name.is_none() { + missing.push(stringify!(snapshot_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_snapshots_delete_snapshot`] + /// + ///[`Client::project_snapshots_delete_snapshot`]: super::Client::project_snapshots_delete_snapshot + #[derive(Clone)] + pub struct ProjectSnapshotsDeleteSnapshot<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + snapshot_name: Option, + } + + impl<'a> ProjectSnapshotsDeleteSnapshot<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + snapshot_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn snapshot_name(mut self, value: types::Name) -> Self { + self.snapshot_name = Some(value); + 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, project_name, snapshot_name) = + match (organization_name, project_name, snapshot_name) { + (Some(organization_name), Some(project_name), Some(snapshot_name)) => { + (organization_name, project_name, snapshot_name) + } + (organization_name, project_name, snapshot_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if snapshot_name.is_none() { + missing.push(stringify!(snapshot_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_vpcs_get`] + /// + ///[`Client::project_vpcs_get`]: super::Client::project_vpcs_get + #[derive(Clone)] + pub struct ProjectVpcsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> ProjectVpcsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name) = match (organization_name, project_name) { + (Some(organization_name), Some(project_name)) => (organization_name, project_name), + (organization_name, project_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::project_vpcs_post`] + /// + ///[`Client::project_vpcs_post`]: super::Client::project_vpcs_post + #[derive(Clone)] + pub struct ProjectVpcsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + body: Option, + } + + impl<'a> ProjectVpcsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcCreate) -> Self { + self.body = Some(value); + 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, project_name, body) = + match (organization_name, project_name, body) { + (Some(organization_name), Some(project_name), Some(body)) => { + (organization_name, project_name, body) + } + (organization_name, project_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/organizations/{}/projects/{}/vpcs", + client.baseurl, + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + ); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_vpcs_get_vpc`] + /// + ///[`Client::project_vpcs_get_vpc`]: super::Client::project_vpcs_get_vpc + #[derive(Clone)] + pub struct ProjectVpcsGetVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> ProjectVpcsGetVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_vpcs_put_vpc`] + /// + ///[`Client::project_vpcs_put_vpc`]: super::Client::project_vpcs_put_vpc + #[derive(Clone)] + pub struct ProjectVpcsPutVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> ProjectVpcsPutVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_vpcs_delete_vpc`] + /// + ///[`Client::project_vpcs_delete_vpc`]: super::Client::project_vpcs_delete_vpc + #[derive(Clone)] + pub struct ProjectVpcsDeleteVpc<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> ProjectVpcsDeleteVpc<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_get`] + /// + ///[`Client::vpc_firewall_rules_get`]: super::Client::vpc_firewall_rules_get + #[derive(Clone)] + pub struct VpcFirewallRulesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + } + + impl<'a> VpcFirewallRulesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_put`] + /// + ///[`Client::vpc_firewall_rules_put`]: super::Client::vpc_firewall_rules_put + #[derive(Clone)] + pub struct VpcFirewallRulesPut<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcFirewallRulesPut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcFirewallRuleUpdateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_routers_get`] + /// + ///[`Client::vpc_routers_get`]: super::Client::vpc_routers_get + #[derive(Clone)] + pub struct VpcRoutersGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> VpcRoutersGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::vpc_routers_post`] + /// + ///[`Client::vpc_routers_post`]: super::Client::vpc_routers_post + #[derive(Clone)] + pub struct VpcRoutersPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcRoutersPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcRouterCreate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_routers_get_router`] + /// + ///[`Client::vpc_routers_get_router`]: super::Client::vpc_routers_get_router + #[derive(Clone)] + pub struct VpcRoutersGetRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + } + + impl<'a> VpcRoutersGetRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_routers_put_router`] + /// + ///[`Client::vpc_routers_put_router`]: super::Client::vpc_routers_put_router + #[derive(Clone)] + pub struct VpcRoutersPutRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + body: Option, + } + + impl<'a> VpcRoutersPutRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcRouterUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, body) = + match (organization_name, project_name, vpc_name, router_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(body), + ) => (organization_name, project_name, vpc_name, router_name, body), + (organization_name, project_name, vpc_name, router_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_routers_delete_router`] + /// + ///[`Client::vpc_routers_delete_router`]: super::Client::vpc_routers_delete_router + #[derive(Clone)] + pub struct VpcRoutersDeleteRouter<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + } + + impl<'a> VpcRoutersDeleteRouter<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::routers_routes_get`] + /// + ///[`Client::routers_routes_get`]: super::Client::routers_routes_get + #[derive(Clone)] + pub struct RoutersRoutesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> RoutersRoutesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name, router_name) = + match (organization_name, project_name, vpc_name, router_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + ) => (organization_name, project_name, vpc_name, router_name), + (organization_name, project_name, vpc_name, router_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::routers_routes_post`] + /// + ///[`Client::routers_routes_post`]: super::Client::routers_routes_post + #[derive(Clone)] + pub struct RoutersRoutesPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + body: Option, + } + + impl<'a> RoutersRoutesPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn body(mut self, value: types::RouterRouteCreateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, body) = + match (organization_name, project_name, vpc_name, router_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(body), + ) => (organization_name, project_name, vpc_name, router_name, body), + (organization_name, project_name, vpc_name, router_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::routers_routes_get_route`] + /// + ///[`Client::routers_routes_get_route`]: super::Client::routers_routes_get_route + #[derive(Clone)] + pub struct RoutersRoutesGetRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + } + + impl<'a> RoutersRoutesGetRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + 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, project_name, vpc_name, router_name, route_name) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ), + (organization_name, project_name, vpc_name, router_name, route_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::routers_routes_put_route`] + /// + ///[`Client::routers_routes_put_route`]: super::Client::routers_routes_put_route + #[derive(Clone)] + pub struct RoutersRoutesPutRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + body: Option, + } + + impl<'a> RoutersRoutesPutRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + self + } + + pub fn body(mut self, value: types::RouterRouteUpdateParams) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, router_name, route_name, body) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + Some(body), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + body, + ), + (organization_name, project_name, vpc_name, router_name, route_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::routers_routes_delete_route`] + /// + ///[`Client::routers_routes_delete_route`]: super::Client::routers_routes_delete_route + #[derive(Clone)] + pub struct RoutersRoutesDeleteRoute<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + router_name: Option, + route_name: Option, + } + + impl<'a> RoutersRoutesDeleteRoute<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + router_name: None, + route_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn router_name(mut self, value: types::Name) -> Self { + self.router_name = Some(value); + self + } + + pub fn route_name(mut self, value: types::Name) -> Self { + self.route_name = Some(value); + 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, project_name, vpc_name, router_name, route_name) = match ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(router_name), + Some(route_name), + ) => ( + organization_name, + project_name, + vpc_name, + router_name, + route_name, + ), + (organization_name, project_name, vpc_name, router_name, route_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if router_name.is_none() { + missing.push(stringify!(router_name)); + } + if route_name.is_none() { + missing.push(stringify!(route_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_subnets_get`] + /// + ///[`Client::vpc_subnets_get`]: super::Client::vpc_subnets_get + #[derive(Clone)] + pub struct VpcSubnetsGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> VpcSubnetsGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name) = + match (organization_name, project_name, vpc_name) { + (Some(organization_name), Some(project_name), Some(vpc_name)) => { + (organization_name, project_name, vpc_name) + } + (organization_name, project_name, vpc_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::vpc_subnets_post`] + /// + ///[`Client::vpc_subnets_post`]: super::Client::vpc_subnets_post + #[derive(Clone)] + pub struct VpcSubnetsPost<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + body: Option, + } + + impl<'a> VpcSubnetsPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcSubnetCreate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, body) = + match (organization_name, project_name, vpc_name, body) { + (Some(organization_name), Some(project_name), Some(vpc_name), Some(body)) => { + (organization_name, project_name, vpc_name, body) + } + (organization_name, project_name, vpc_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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_subnets_get_subnet`] + /// + ///[`Client::vpc_subnets_get_subnet`]: super::Client::vpc_subnets_get_subnet + #[derive(Clone)] + pub struct VpcSubnetsGetSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + } + + impl<'a> VpcSubnetsGetSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_subnets_put_subnet`] + /// + ///[`Client::vpc_subnets_put_subnet`]: super::Client::vpc_subnets_put_subnet + #[derive(Clone)] + pub struct VpcSubnetsPutSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + body: Option, + } + + impl<'a> VpcSubnetsPutSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + body: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + self + } + + pub fn body(mut self, value: types::VpcSubnetUpdate) -> Self { + self.body = Some(value); + 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, project_name, vpc_name, subnet_name, body) = + match (organization_name, project_name, vpc_name, subnet_name, body) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + Some(body), + ) => (organization_name, project_name, vpc_name, subnet_name, body), + (organization_name, project_name, vpc_name, subnet_name, body) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_subnets_delete_subnet`] + /// + ///[`Client::vpc_subnets_delete_subnet`]: super::Client::vpc_subnets_delete_subnet + #[derive(Clone)] + pub struct VpcSubnetsDeleteSubnet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + } + + impl<'a> VpcSubnetsDeleteSubnet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::subnet_network_interfaces_get`] + /// + ///[`Client::subnet_network_interfaces_get`]: super::Client::subnet_network_interfaces_get + #[derive(Clone)] + pub struct SubnetNetworkInterfacesGet<'a> { + client: &'a super::Client, + organization_name: Option, + project_name: Option, + vpc_name: Option, + subnet_name: Option, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SubnetNetworkInterfacesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + organization_name: None, + project_name: None, + vpc_name: None, + subnet_name: None, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn organization_name(mut self, value: types::Name) -> Self { + self.organization_name = Some(value); + self + } + + pub fn project_name(mut self, value: types::Name) -> Self { + self.project_name = Some(value); + self + } + + pub fn vpc_name(mut self, value: types::Name) -> Self { + self.vpc_name = Some(value); + self + } + + pub fn subnet_name(mut self, value: types::Name) -> Self { + self.subnet_name = Some(value); + self + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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, project_name, vpc_name, subnet_name) = + match (organization_name, project_name, vpc_name, subnet_name) { + ( + Some(organization_name), + Some(project_name), + Some(vpc_name), + Some(subnet_name), + ) => (organization_name, project_name, vpc_name, subnet_name), + (organization_name, project_name, vpc_name, subnet_name) => { + let mut missing = Vec::new(); + if organization_name.is_none() { + missing.push(stringify!(organization_name)); + } + if project_name.is_none() { + missing.push(stringify!(project_name)); + } + if vpc_name.is_none() { + missing.push(stringify!(vpc_name)); + } + if subnet_name.is_none() { + missing.push(stringify!(subnet_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + 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 mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::policy_get`] + /// + ///[`Client::policy_get`]: super::Client::policy_get + #[derive(Clone)] + pub struct PolicyGet<'a> { + client: &'a super::Client, + } + + impl<'a> PolicyGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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_put`] + /// + ///[`Client::policy_put`]: super::Client::policy_put + #[derive(Clone)] + pub struct PolicyPut<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> PolicyPut<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::FleetRolesPolicy) -> Self { + self.body = Some(value); + self + } + + ///Sends a `PUT` request to `/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/policy", client.baseurl,); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::roles_get`] + /// + ///[`Client::roles_get`]: super::Client::roles_get + #[derive(Clone)] + pub struct RolesGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + } + + impl<'a> RolesGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + ///Sends a `GET` request to `/roles` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + } = self; + let url = format!("{}/roles", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::roles_get_role`] + /// + ///[`Client::roles_get_role`]: super::Client::roles_get_role + #[derive(Clone)] + pub struct RolesGetRole<'a> { + client: &'a super::Client, + role_name: Option, + } + + impl<'a> RolesGetRole<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + role_name: None, + } + } + + pub fn role_name(mut self, value: S) -> Self { + self.role_name = Some(value.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,) = match (role_name,) { + (Some(role_name),) => (role_name,), + (role_name,) => { + let mut missing = Vec::new(); + if role_name.is_none() { + missing.push(stringify!(role_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/roles/{}", + client.baseurl, + encode_path(&role_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::sagas_get`] + /// + ///[`Client::sagas_get`]: super::Client::sagas_get + #[derive(Clone)] + pub struct SagasGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SagasGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::IdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/sagas` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/sagas", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/sagas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::sagas_get_saga`] + /// + ///[`Client::sagas_get_saga`]: super::Client::sagas_get_saga + #[derive(Clone)] + pub struct SagasGetSaga<'a> { + client: &'a super::Client, + saga_id: Option, + } + + impl<'a> SagasGetSaga<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + saga_id: None, + } + } + + pub fn saga_id(mut self, value: uuid::Uuid) -> Self { + self.saga_id = Some(value); + self + } + + ///Sends a `GET` request to `/sagas/{saga_id}` + pub async fn send(self) -> Result, Error> { + let Self { client, saga_id } = self; + let (saga_id,) = match (saga_id,) { + (Some(saga_id),) => (saga_id,), + (saga_id,) => { + let mut missing = Vec::new(); + if saga_id.is_none() { + missing.push(stringify!(saga_id)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/sagas/{}", + client.baseurl, + encode_path(&saga_id.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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(Clone)] + pub struct SessionMe<'a> { + client: &'a super::Client, + } + + impl<'a> SessionMe<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { 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 = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::sshkeys_get`] + /// + ///[`Client::sshkeys_get`]: super::Client::sshkeys_get + #[derive(Clone)] + pub struct SshkeysGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SshkeysGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + 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 url = format!("{}/session/me/sshkeys", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::sshkeys_post`] + /// + ///[`Client::sshkeys_post`]: super::Client::sshkeys_post + #[derive(Clone)] + pub struct SshkeysPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SshkeysPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::SshKeyCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/session/me/sshkeys` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/session/me/sshkeys", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::sshkeys_get_key`] + /// + ///[`Client::sshkeys_get_key`]: super::Client::sshkeys_get_key + #[derive(Clone)] + pub struct SshkeysGetKey<'a> { + client: &'a super::Client, + ssh_key_name: Option, + } + + impl<'a> SshkeysGetKey<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + ssh_key_name: None, + } + } + + pub fn ssh_key_name(mut self, value: types::Name) -> Self { + self.ssh_key_name = Some(value); + 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,) = match (ssh_key_name,) { + (Some(ssh_key_name),) => (ssh_key_name,), + (ssh_key_name,) => { + let mut missing = Vec::new(); + if ssh_key_name.is_none() { + missing.push(stringify!(ssh_key_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::sshkeys_delete_key`] + /// + ///[`Client::sshkeys_delete_key`]: super::Client::sshkeys_delete_key + #[derive(Clone)] + pub struct SshkeysDeleteKey<'a> { + client: &'a super::Client, + ssh_key_name: Option, + } + + impl<'a> SshkeysDeleteKey<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + ssh_key_name: None, + } + } + + pub fn ssh_key_name(mut self, value: types::Name) -> Self { + self.ssh_key_name = Some(value); + 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,) = match (ssh_key_name,) { + (Some(ssh_key_name),) => (ssh_key_name,), + (ssh_key_name,) => { + let mut missing = Vec::new(); + if ssh_key_name.is_none() { + missing.push(stringify!(ssh_key_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/session/me/sshkeys/{}", + client.baseurl, + encode_path(&ssh_key_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::silos_get`] + /// + ///[`Client::silos_get`]: super::Client::silos_get + #[derive(Clone)] + pub struct SilosGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> SilosGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameOrIdSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/silos` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/silos", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 `/silos` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::silos_post`] + /// + ///[`Client::silos_post`]: super::Client::silos_post + #[derive(Clone)] + pub struct SilosPost<'a> { + client: &'a super::Client, + body: Option, + } + + impl<'a> SilosPost<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client, body: None } + } + + pub fn body(mut self, value: types::SiloCreate) -> Self { + self.body = Some(value); + self + } + + ///Sends a `POST` request to `/silos` + pub async fn send(self) -> Result, Error> { + let Self { client, body } = self; + let (body,) = match (body,) { + (Some(body),) => (body,), + (body,) => { + let mut missing = Vec::new(); + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!("{}/silos", client.baseurl,); + let request = client.client.post(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::silos_get_silo`] + /// + ///[`Client::silos_get_silo`]: super::Client::silos_get_silo + #[derive(Clone)] + pub struct SilosGetSilo<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosGetSilo<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `GET` request to `/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::silos_delete_silo`] + /// + ///[`Client::silos_delete_silo`]: super::Client::silos_delete_silo + #[derive(Clone)] + pub struct SilosDeleteSilo<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosDeleteSilo<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `DELETE` request to `/silos/{silo_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.delete(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::silos_get_silo_policy`] + /// + ///[`Client::silos_get_silo_policy`]: super::Client::silos_get_silo_policy + #[derive(Clone)] + pub struct SilosGetSiloPolicy<'a> { + client: &'a super::Client, + silo_name: Option, + } + + impl<'a> SilosGetSiloPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + ///Sends a `GET` request to `/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, silo_name } = self; + let (silo_name,) = match (silo_name,) { + (Some(silo_name),) => (silo_name,), + (silo_name,) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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::silos_put_silo_policy`] + /// + ///[`Client::silos_put_silo_policy`]: super::Client::silos_put_silo_policy + #[derive(Clone)] + pub struct SilosPutSiloPolicy<'a> { + client: &'a super::Client, + silo_name: Option, + body: Option, + } + + impl<'a> SilosPutSiloPolicy<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + silo_name: None, + body: None, + } + } + + pub fn silo_name(mut self, value: types::Name) -> Self { + self.silo_name = Some(value); + self + } + + pub fn body(mut self, value: types::SiloRolesPolicy) -> Self { + self.body = Some(value); + self + } + + ///Sends a `PUT` request to `/silos/{silo_name}/policy` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + silo_name, + body, + } = self; + let (silo_name, body) = match (silo_name, body) { + (Some(silo_name), Some(body)) => (silo_name, body), + (silo_name, body) => { + let mut missing = Vec::new(); + if silo_name.is_none() { + missing.push(stringify!(silo_name)); + } + if body.is_none() { + missing.push(stringify!(body)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/silos/{}/policy", + client.baseurl, + encode_path(&silo_name.to_string()), + ); + let request = client.client.put(url).json(&body).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => 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(Clone)] + pub struct TimeseriesSchemaGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + } + + impl<'a> TimeseriesSchemaGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + ///Sends a `GET` request to `/timeseries/schema` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + } = self; + let url = format!("{}/timeseries/schema", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::updates_refresh`] + /// + ///[`Client::updates_refresh`]: super::Client::updates_refresh + #[derive(Clone)] + pub struct UpdatesRefresh<'a> { + client: &'a super::Client, + } + + impl<'a> UpdatesRefresh<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { client } + } + + ///Sends a `POST` request to `/updates/refresh` + pub async fn send(self) -> Result, Error> { + let Self { client } = self; + let url = format!("{}/updates/refresh", client.baseurl,); + let request = client.client.post(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 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::users_get`] + /// + ///[`Client::users_get`]: super::Client::users_get + #[derive(Clone)] + pub struct UsersGet<'a> { + client: &'a super::Client, + limit: Option, + page_token: Option, + sort_by: Option, + } + + impl<'a> UsersGet<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + limit: None, + page_token: None, + sort_by: None, + } + } + + pub fn limit(mut self, value: std::num::NonZeroU32) -> Self { + self.limit = Some(value); + self + } + + pub fn page_token(mut self, value: String) -> Self { + self.page_token = Some(value); + self + } + + pub fn sort_by(mut self, value: types::NameSortMode) -> Self { + self.sort_by = Some(value); + self + } + + ///Sends a `GET` request to `/users` + pub async fn send( + self, + ) -> Result, Error> { + let Self { + client, + limit, + page_token, + sort_by, + } = self; + let url = format!("{}/users", client.baseurl,); + let mut query = Vec::new(); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + if let Some(v) = &sort_by { + query.push(("sort_by", v.to_string())); + } + let request = client.client.get(url).query(&query).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 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 { + limit: None, + page_token: None, + sort_by: None, + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items.into_iter().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: next_page, + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items.into_iter().map(Ok)), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + + ///Builder for [`Client::users_get_user`] + /// + ///[`Client::users_get_user`]: super::Client::users_get_user + #[derive(Clone)] + pub struct UsersGetUser<'a> { + client: &'a super::Client, + user_name: Option, + } + + impl<'a> UsersGetUser<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client, + user_name: None, + } + } + + pub fn user_name(mut self, value: types::Name) -> Self { + self.user_name = Some(value); + self + } + + ///Sends a `GET` request to `/users/{user_name}` + pub async fn send(self) -> Result, Error> { + let Self { client, user_name } = self; + let (user_name,) = match (user_name,) { + (Some(user_name),) => (user_name,), + (user_name,) => { + let mut missing = Vec::new(); + if user_name.is_none() { + missing.push(stringify!(user_name)); + } + return Err(super::Error::InvalidRequest(format!( + "the following parameters are required: {}", + missing.join(", "), + ))); + } + }; + let url = format!( + "{}/users/{}", + client.baseurl, + encode_path(&user_name.to_string()), + ); + let request = client.client.get(url).build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } +} diff --git a/progenitor-impl/tests/output/nexus.out b/progenitor-impl/tests/output/nexus-positional.out similarity index 71% rename from progenitor-impl/tests/output/nexus.out rename to progenitor-impl/tests/output/nexus-positional.out index c48b12b..e3ace1a 100644 --- a/progenitor-impl/tests/output/nexus.out +++ b/progenitor-impl/tests/output/nexus-positional.out @@ -1,3 +1,5 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; @@ -21,7 +23,13 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ByteCount(pub u64); impl std::ops::Deref for ByteCount { @@ -31,7 +39,7 @@ pub mod types { } } - #[doc = "The type of an individual datum of a metric."] + ///The type of an individual datum of a metric. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum DatumType { #[serde(rename = "bool")] @@ -91,79 +99,82 @@ pub mod types { } } - #[doc = "Client view of an [`Disk`]"] + ///Client view of an [`Disk`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Disk { pub block_size: ByteCount, - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, pub device_path: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, #[serde(default, skip_serializing_if = "Option::is_none")] pub image_id: Option, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, pub project_id: uuid::Uuid, pub size: ByteCount, #[serde(default, skip_serializing_if = "Option::is_none")] pub snapshot_id: Option, pub state: DiskState, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for a [`Disk`](omicron_common::api::external::Disk)"] + ///Create-time parameters for a + /// [`Disk`](omicron_common::api::external::Disk) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DiskCreate { pub description: String, - #[doc = "initial source for this disk"] + ///initial source for this disk pub disk_source: DiskSource, pub name: Name, - #[doc = "total size of the Disk in bytes"] + ///total size of the Disk in bytes pub size: ByteCount, } - #[doc = "Parameters for the [`Disk`](omicron_common::api::external::Disk) to be attached or detached to an instance"] + ///Parameters for the [`Disk`](omicron_common::api::external::Disk) to be + /// attached or detached to an instance #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DiskIdentifier { pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct DiskResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Different sources for a disk"] + ///Different sources for a disk #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type")] pub enum DiskSource { - #[doc = "Create a blank disk"] + ///Create a blank disk #[serde(rename = "blank")] Blank { - #[doc = "size of blocks for this Disk. valid values are: 512, 2048, or 4096"] + ///size of blocks for this Disk. valid values are: 512, 2048, or + /// 4096 block_size: BlockSize, }, - #[doc = "Create a disk from a disk snapshot"] + ///Create a disk from a disk snapshot #[serde(rename = "snapshot")] Snapshot { snapshot_id: uuid::Uuid }, - #[doc = "Create a disk from a project image"] + ///Create a disk from a project image #[serde(rename = "image")] Image { image_id: uuid::Uuid }, - #[doc = "Create a disk from a global image"] + ///Create a disk from a global image #[serde(rename = "global_image")] GlobalImage { image_id: uuid::Uuid }, } - #[doc = "State of a Disk (primarily: attached or not)"] + ///State of a Disk (primarily: attached or not) #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "state", content = "instance")] pub enum DiskState { @@ -171,13 +182,13 @@ pub mod types { Creating, #[serde(rename = "detached")] Detached, - #[doc = "Disk is being attached to the given Instance"] + ///Disk is being attached to the given Instance #[serde(rename = "attaching")] Attaching(uuid::Uuid), - #[doc = "Disk is attached to the given Instance"] + ///Disk is attached to the given Instance #[serde(rename = "attached")] Attached(uuid::Uuid), - #[doc = "Disk is being detached from the given Instance"] + ///Disk is being detached from the given Instance #[serde(rename = "detaching")] Detaching(uuid::Uuid), #[serde(rename = "destroyed")] @@ -186,7 +197,7 @@ pub mod types { Faulted, } - #[doc = "Error information from a response."] + ///Error information from a response. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -195,7 +206,7 @@ pub mod types { pub request_id: String, } - #[doc = "The name and type information for a field of a timeseries schema."] + ///The name and type information for a field of a timeseries schema. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct FieldSchema { pub name: String, @@ -203,7 +214,7 @@ pub mod types { pub ty: FieldType, } - #[doc = "The source from which a field is derived, the target or metric."] + ///The source from which a field is derived, the target or metric. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum FieldSource { #[serde(rename = "target")] @@ -221,7 +232,7 @@ pub mod types { } } - #[doc = "The `FieldType` identifies the data type of a target or metric field."] + ///The `FieldType` identifies the data type of a target or metric field. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum FieldType { #[serde(rename = "string")] @@ -268,14 +279,24 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct FleetRolesPolicy { - #[doc = "Roles directly assigned on this resource"] + ///Roles directly assigned on this resource pub role_assignments: Vec, } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct FleetRolesRoleAssignment { pub identity_id: uuid::Uuid, @@ -283,45 +304,47 @@ pub mod types { pub role_name: FleetRoles, } - #[doc = "Client view of global Images"] + ///Client view of global Images #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GlobalImage { - #[doc = "size of blocks in bytes"] + ///size of blocks in bytes pub block_size: ByteCount, - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "Hash of the image contents, if applicable"] + ///Hash of the image contents, if applicable #[serde(default, skip_serializing_if = "Option::is_none")] pub digest: Option, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "total size in bytes"] + ///total size in bytes pub size: ByteCount, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "URL source of this image, if any"] + ///URL source of this image, if any #[serde(default, skip_serializing_if = "Option::is_none")] pub url: Option, - #[doc = "Version of this, if any"] + ///Version of this, if any #[serde(default, skip_serializing_if = "Option::is_none")] pub version: Option, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GlobalImageResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Supported set of sort modes for scanning by id only.\n\nCurrently, we only support scanning in ascending order."] + ///Supported set of sort modes for scanning by id only. + /// + ///Currently, we only support scanning in ascending order. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum IdSortMode { #[serde(rename = "id_ascending")] @@ -336,7 +359,7 @@ pub mod types { } } - #[doc = "Describes what kind of identity is described by an id"] + ///Describes what kind of identity is described by an id #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum IdentityType { #[serde(rename = "silo_user")] @@ -351,58 +374,59 @@ pub mod types { } } - #[doc = "Client view of project Images"] + ///Client view of project Images #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Image { - #[doc = "size of blocks in bytes"] + ///size of blocks in bytes pub block_size: ByteCount, - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "Hash of the image contents, if applicable"] + ///Hash of the image contents, if applicable #[serde(default, skip_serializing_if = "Option::is_none")] pub digest: Option, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "The project the disk belongs to"] + ///The project the disk belongs to pub project_id: uuid::Uuid, - #[doc = "total size in bytes"] + ///total size in bytes pub size: ByteCount, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "URL source of this image, if any"] + ///URL source of this image, if any #[serde(default, skip_serializing_if = "Option::is_none")] pub url: Option, - #[doc = "Version of this, if any"] + ///Version of this, if any #[serde(default, skip_serializing_if = "Option::is_none")] pub version: Option, } - #[doc = "Create-time parameters for an [`Image`](omicron_common::api::external::Image)"] + ///Create-time parameters for an + /// [`Image`](omicron_common::api::external::Image) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ImageCreate { - #[doc = "block size in bytes"] + ///block size in bytes pub block_size: BlockSize, pub description: String, pub name: Name, - #[doc = "The source of the image's contents."] + ///The source of the image's contents. pub source: ImageSource, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ImageResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "The source of the underlying image."] + ///The source of the underlying image. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "src")] pub enum ImageSource { @@ -412,32 +436,32 @@ pub mod types { Snapshot(uuid::Uuid), } - #[doc = "Client view of an [`Instance`]"] + ///Client view of an [`Instance`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Instance { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "RFC1035-compliant hostname for the Instance."] + ///RFC1035-compliant hostname for the Instance. pub hostname: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "memory allocated for this Instance"] + ///memory allocated for this Instance pub memory: ByteCount, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "number of CPUs allocated for this Instance"] + ///number of CPUs allocated for this Instance pub ncpus: InstanceCpuCount, - #[doc = "id for the project containing this Instance"] + ///id for the project containing this Instance pub project_id: uuid::Uuid, pub run_state: InstanceState, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, pub time_run_state_updated: chrono::DateTime, } - #[doc = "The number of CPUs in an Instance"] + ///The number of CPUs in an Instance #[derive(Serialize, Deserialize, Debug, Clone)] pub struct InstanceCpuCount(pub u16); impl std::ops::Deref for InstanceCpuCount { @@ -447,21 +471,24 @@ pub mod types { } } - #[doc = "Create-time parameters for an [`Instance`](omicron_common::api::external::Instance)"] + ///Create-time parameters for an + /// [`Instance`](omicron_common::api::external::Instance) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct InstanceCreate { pub description: String, - #[doc = "The disks to be created or attached for this instance."] + ///The disks to be created or attached for this instance. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub disks: Vec, pub hostname: String, pub memory: ByteCount, pub name: Name, pub ncpus: InstanceCpuCount, - #[doc = "The network interfaces to be created for this instance."] + ///The network interfaces to be created for this instance. #[serde(default = "instance_create_network_interfaces")] pub network_interfaces: InstanceNetworkInterfaceAttachment, - #[doc = "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."] + ///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: String, } @@ -470,39 +497,41 @@ pub mod types { InstanceNetworkInterfaceAttachment::Default } - #[doc = "Describe the instance's disks at creation time"] + ///Describe the instance's disks at creation time #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type")] pub enum InstanceDiskAttachment { - #[doc = "During instance creation, create and attach disks"] + ///During instance creation, create and attach disks #[serde(rename = "create")] Create { description: String, - #[doc = "initial source for this disk"] + ///initial source for this disk disk_source: DiskSource, name: Name, - #[doc = "total size of the Disk in bytes"] + ///total size of the Disk in bytes size: ByteCount, }, - #[doc = "During instance creation, attach this disk"] + ///During instance creation, attach this disk #[serde(rename = "attach")] Attach { - #[doc = "A disk name to attach"] + ///A disk name to attach name: Name, }, } - #[doc = "Migration parameters for an [`Instance`](omicron_common::api::external::Instance)"] + ///Migration parameters for an + /// [`Instance`](omicron_common::api::external::Instance) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct InstanceMigrate { pub dst_sled_uuid: uuid::Uuid, } - #[doc = "Describes an attachment of a `NetworkInterface` to an `Instance`, at the time the instance is created."] + ///Describes an attachment of a `NetworkInterface` to an `Instance`, at the + /// time the instance is created. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "params")] pub enum InstanceNetworkInterfaceAttachment { - #[doc = "Create one or more `NetworkInterface`s for the `Instance`"] + ///Create one or more `NetworkInterface`s for the `Instance` #[serde(rename = "create")] Create(Vec), #[serde(rename = "default")] @@ -511,17 +540,20 @@ pub mod types { None, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct InstanceResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "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"] + ///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 #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum InstanceState { #[serde(rename = "creating")] @@ -570,7 +602,7 @@ pub mod types { V6(Ipv6Net), } - #[doc = "An IPv4 subnet, including prefix and subnet mask"] + ///An IPv4 subnet, including prefix and subnet mask #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Ipv4Net(pub String); impl std::ops::Deref for Ipv4Net { @@ -580,7 +612,7 @@ pub mod types { } } - #[doc = "An IPv6 subnet, including prefix and subnet mask"] + ///An IPv6 subnet, including prefix and subnet mask #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Ipv6Net(pub String); impl std::ops::Deref for Ipv6Net { @@ -590,7 +622,8 @@ pub mod types { } } - #[doc = "An inclusive-inclusive range of IP ports. The second port may be omitted to represent a single port"] + ///An inclusive-inclusive range of IP ports. The second port may be omitted + /// to represent a single port #[derive(Serialize, Deserialize, Debug, Clone)] pub struct L4PortRange(pub String); impl std::ops::Deref for L4PortRange { @@ -605,7 +638,7 @@ pub mod types { pub username: String, } - #[doc = "A Media Access Control address, in EUI-48 format"] + ///A Media Access Control address, in EUI-48 format #[derive(Serialize, Deserialize, Debug, Clone)] pub struct MacAddr(pub String); impl std::ops::Deref for MacAddr { @@ -615,7 +648,9 @@ pub mod types { } } - #[doc = "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 must begin with a lower case ASCII letter, be composed exclusively + /// of lowercase ASCII, uppercase ASCII, numbers, and '-', and may not end + /// with a '-'. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Name(pub String); impl std::ops::Deref for Name { @@ -625,7 +660,7 @@ pub mod types { } } - #[doc = "Supported set of sort modes for scanning by name or id"] + ///Supported set of sort modes for scanning by name or id #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum NameOrIdSortMode { #[serde(rename = "name_ascending")] @@ -646,7 +681,9 @@ pub mod types { } } - #[doc = "Supported set of sort modes for scanning by name only\n\nCurrently, we only support scanning in ascending order."] + ///Supported set of sort modes for scanning by name only + /// + ///Currently, we only support scanning in ascending order. #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum NameSortMode { #[serde(rename = "name_ascending")] @@ -661,83 +698,86 @@ pub mod types { } } - #[doc = "A `NetworkInterface` represents a virtual network interface device."] + ///A `NetworkInterface` represents a virtual network interface device. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct NetworkInterface { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "The Instance to which the interface belongs."] + ///The Instance to which the interface belongs. pub instance_id: uuid::Uuid, - #[doc = "The IP address assigned to this interface."] + ///The IP address assigned to this interface. pub ip: String, - #[doc = "The MAC address assigned to this interface."] + ///The MAC address assigned to this interface. pub mac: MacAddr, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "The subnet to which the interface belongs."] + ///The subnet to which the interface belongs. pub subnet_id: uuid::Uuid, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "The VPC to which the interface belongs."] + ///The VPC to which the interface belongs. pub vpc_id: uuid::Uuid, } - #[doc = "Create-time parameters for a [`NetworkInterface`](omicron_common::api::external::NetworkInterface)"] + ///Create-time parameters for a + /// [`NetworkInterface`](omicron_common::api::external::NetworkInterface) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct NetworkInterfaceCreate { pub description: String, - #[doc = "The IP address for the interface. One will be auto-assigned if not provided."] + ///The IP address for the interface. One will be auto-assigned if not + /// provided. #[serde(default, skip_serializing_if = "Option::is_none")] pub ip: Option, pub name: Name, - #[doc = "The VPC Subnet in which to create the interface."] + ///The VPC Subnet in which to create the interface. pub subnet_name: Name, - #[doc = "The VPC in which to create the interface."] + ///The VPC in which to create the interface. pub vpc_name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct NetworkInterfaceResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of an [`Organization`]"] + ///Client view of an [`Organization`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Organization { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for an [`Organization`](crate::external_api::views::Organization)"] + ///Create-time parameters for an + /// [`Organization`](crate::external_api::views::Organization) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OrganizationCreate { pub description: String, pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OrganizationResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } @@ -759,14 +799,24 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OrganizationRolesPolicy { - #[doc = "Roles directly assigned on this resource"] + ///Roles directly assigned on this resource pub role_assignments: Vec, } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OrganizationRolesRoleAssignment { pub identity_id: uuid::Uuid, @@ -774,7 +824,8 @@ pub mod types { pub role_name: OrganizationRoles, } - #[doc = "Updateable properties of an [`Organization`](crate::external_api::views::Organization)"] + ///Updateable properties of an + /// [`Organization`](crate::external_api::views::Organization) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OrganizationUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -783,35 +834,36 @@ pub mod types { pub name: Option, } - #[doc = "Client view of a [`Project`]"] + ///Client view of a [`Project`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Project { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, pub organization_id: uuid::Uuid, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for a [`Project`](crate::external_api::views::Project)"] + ///Create-time parameters for a + /// [`Project`](crate::external_api::views::Project) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProjectCreate { pub description: String, pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProjectResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } @@ -836,14 +888,24 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProjectRolesPolicy { - #[doc = "Roles directly assigned on this resource"] + ///Roles directly assigned on this resource pub role_assignments: Vec, } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProjectRolesRoleAssignment { pub identity_id: uuid::Uuid, @@ -851,7 +913,8 @@ pub mod types { pub role_name: ProjectRoles, } - #[doc = "Updateable properties of a [`Project`](crate::external_api::views::Project)"] + ///Updateable properties of a + /// [`Project`](crate::external_api::views::Project) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProjectUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -860,39 +923,39 @@ pub mod types { pub name: Option, } - #[doc = "Client view of an [`Rack`]"] + ///Client view of an [`Rack`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Rack { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RackResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of a [`Role`]"] + ///Client view of a [`Role`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Role { pub description: String, pub name: RoleName, } - #[doc = "Role names consist of two string components separated by dot (\".\")."] + ///Role names consist of two string components separated by dot ("."). #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RoleName(pub String); impl std::ops::Deref for RoleName { @@ -902,77 +965,84 @@ pub mod types { } } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RoleResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "value")] pub enum RouteDestination { - #[doc = "Route applies to traffic destined for a specific IP address"] + ///Route applies to traffic destined for a specific IP address #[serde(rename = "ip")] Ip(String), - #[doc = "Route applies to traffic destined for a specific IP subnet"] + ///Route applies to traffic destined for a specific IP subnet #[serde(rename = "ip_net")] IpNet(IpNet), - #[doc = "Route applies to traffic destined for the given VPC."] + ///Route applies to traffic destined for the given VPC. #[serde(rename = "vpc")] Vpc(Name), - #[doc = "Route applies to traffic"] + ///Route applies to traffic #[serde(rename = "subnet")] Subnet(Name), } - #[doc = "A `RouteTarget` describes the possible locations that traffic matching a route destination can be sent."] + ///A `RouteTarget` describes the possible locations that traffic matching a + /// route destination can be sent. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "value")] pub enum RouteTarget { - #[doc = "Forward traffic to a particular IP address."] + ///Forward traffic to a particular IP address. #[serde(rename = "ip")] Ip(String), - #[doc = "Forward traffic to a VPC"] + ///Forward traffic to a VPC #[serde(rename = "vpc")] Vpc(Name), - #[doc = "Forward traffic to a VPC Subnet"] + ///Forward traffic to a VPC Subnet #[serde(rename = "subnet")] Subnet(Name), - #[doc = "Forward traffic to a specific instance"] + ///Forward traffic to a specific instance #[serde(rename = "instance")] Instance(Name), - #[doc = "Forward traffic to an internet gateway"] + ///Forward traffic to an internet gateway #[serde(rename = "internet_gateway")] InternetGateway(Name), } - #[doc = "A route defines a rule that governs where traffic should be sent based on its destination."] + ///A route defines a rule that governs where traffic should be sent based + /// on its destination. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RouterRoute { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, pub destination: RouteDestination, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "Describes the kind of router. Set at creation. `read-only`"] + ///Describes the kind of router. Set at creation. `read-only` pub kind: RouterRouteKind, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, pub target: RouteTarget, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "The VPC Router to which the route belongs."] + ///The VPC Router to which the route belongs. pub vpc_router_id: uuid::Uuid, } - #[doc = "Create-time parameters for a [`RouterRoute`]"] + ///Create-time parameters for a [`RouterRoute`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RouterRouteCreateParams { pub description: String, @@ -981,7 +1051,11 @@ pub mod types { pub target: RouteTarget, } - #[doc = "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"] + ///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 #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum RouterRouteKind { #[serde(rename = "default")] @@ -1005,17 +1079,17 @@ pub mod types { } } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RouterRouteResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Updateable properties of a [`RouterRoute`]"] + ///Updateable properties of a [`RouterRoute`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RouterRouteUpdateParams { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1047,12 +1121,12 @@ pub mod types { SubsagaCreateFailed { message: String }, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SagaResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } @@ -1071,30 +1145,31 @@ pub mod types { }, } - #[doc = "Client view of currently authed user."] + ///Client view of currently authed user. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SessionUser { pub id: uuid::Uuid, } - #[doc = "Client view of a ['Silo']"] + ///Client view of a ['Silo'] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Silo { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "A silo where discoverable is false can be retrieved only by its id - it will not be part of the \"list all silos\" output."] + ///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, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for a [`Silo`](crate::external_api::views::Silo)"] + ///Create-time parameters for a [`Silo`](crate::external_api::views::Silo) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SiloCreate { pub description: String, @@ -1102,12 +1177,12 @@ pub mod types { pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SiloResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } @@ -1132,14 +1207,24 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SiloRolesPolicy { - #[doc = "Roles directly assigned on this resource"] + ///Roles directly assigned on this resource pub role_assignments: Vec, } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SiloRolesRoleAssignment { pub identity_id: uuid::Uuid, @@ -1147,108 +1232,112 @@ pub mod types { pub role_name: SiloRoles, } - #[doc = "Client view of an [`Sled`]"] + ///Client view of an [`Sled`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Sled { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, pub service_address: String, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SledResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of a Snapshot"] + ///Client view of a Snapshot #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Snapshot { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, pub disk_id: uuid::Uuid, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, pub project_id: uuid::Uuid, pub size: ByteCount, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for a [`Snapshot`](omicron_common::api::external::Snapshot)"] + ///Create-time parameters for a + /// [`Snapshot`](omicron_common::api::external::Snapshot) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SnapshotCreate { pub description: String, - #[doc = "The name of the disk to be snapshotted"] + ///The name of the disk to be snapshotted pub disk: Name, pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SnapshotResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of a [`SshKey`]"] + ///Client view of a [`SshKey`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SshKey { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "SSH public key, e.g., `\"ssh-ed25519 AAAAC3NzaC...\"`"] + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` pub public_key: String, - #[doc = "The user to whom this key belongs"] + ///The user to whom this key belongs pub silo_user_id: uuid::Uuid, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for an [`SshKey`](crate::external_api::views::SshKey)"] + ///Create-time parameters for an + /// [`SshKey`](crate::external_api::views::SshKey) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SshKeyCreate { pub description: String, pub name: Name, - #[doc = "SSH public key, e.g., `\"ssh-ed25519 AAAAC3NzaC...\"`"] + ///SSH public key, e.g., `"ssh-ed25519 AAAAC3NzaC..."` pub public_key: String, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct SshKeyResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Names are constructed by concatenating the target and metric names with ':'. Target and metric names must be lowercase alphanumeric characters with '_' separating words."] + ///Names are constructed by concatenating the target and metric names with + /// ':'. Target and metric names must be lowercase alphanumeric characters + /// with '_' separating words. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct TimeseriesName(pub String); impl std::ops::Deref for TimeseriesName { @@ -1258,7 +1347,10 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct TimeseriesSchema { pub created: chrono::DateTime, @@ -1267,101 +1359,106 @@ pub mod types { pub timeseries_name: TimeseriesName, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct TimeseriesSchemaResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of a [`User`]"] + ///Client view of a [`User`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct User { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct UserResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Client view of a [`Vpc`]"] + ///Client view of a [`Vpc`] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Vpc { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "The name used for the VPC in DNS."] + ///The name used for the VPC in DNS. pub dns_name: Name, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "The unique local IPv6 address range for subnets in this VPC"] + ///The unique local IPv6 address range for subnets in this VPC pub ipv6_prefix: Ipv6Net, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "id for the project containing this VPC"] + ///id for the project containing this VPC pub project_id: uuid::Uuid, - #[doc = "id for the system router where subnet default routes are registered"] + ///id for the system router where subnet default routes are registered pub system_router_id: uuid::Uuid, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, } - #[doc = "Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc)"] + ///Create-time parameters for a [`Vpc`](crate::external_api::views::Vpc) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcCreate { pub description: String, pub dns_name: Name, - #[doc = "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."] + ///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 = "Option::is_none")] pub ipv6_prefix: Option, pub name: Name, } - #[doc = "A single rule in a VPC firewall"] + ///A single rule in a VPC firewall #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcFirewallRule { - #[doc = "whether traffic matching the rule should be allowed or dropped"] + ///whether traffic matching the rule should be allowed or dropped pub action: VpcFirewallRuleAction, - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "whether this rule is for incoming or outgoing traffic"] + ///whether this rule is for incoming or outgoing traffic pub direction: VpcFirewallRuleDirection, - #[doc = "reductions on the scope of the rule"] + ///reductions on the scope of the rule pub filters: VpcFirewallRuleFilter, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "the relative priority of this rule"] + ///the relative priority of this rule pub priority: u16, - #[doc = "whether this rule is in effect"] + ///whether this rule is in effect pub status: VpcFirewallRuleStatus, - #[doc = "list of sets of instances that the rule applies to"] + ///list of sets of instances that the rule applies to pub targets: Vec, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "the VPC to which this rule belongs"] + ///the VPC to which this rule belongs pub vpc_id: uuid::Uuid, } @@ -1399,42 +1496,46 @@ pub mod types { } } - #[doc = "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."] + ///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. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcFirewallRuleFilter { - #[doc = "If present, the sources (if incoming) or destinations (if outgoing) this rule applies to."] + ///If present, the sources (if incoming) or destinations (if outgoing) + /// this rule applies to. #[serde(default, skip_serializing_if = "Option::is_none")] pub hosts: Option>, - #[doc = "If present, the destination ports this rule applies to."] + ///If present, the destination ports this rule applies to. #[serde(default, skip_serializing_if = "Option::is_none")] pub ports: Option>, - #[doc = "If present, the networking protocols this rule applies to."] + ///If present, the networking protocols this rule applies to. #[serde(default, skip_serializing_if = "Option::is_none")] pub protocols: Option>, } - #[doc = "The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis of its source or destination host."] + ///The `VpcFirewallRuleHostFilter` is used to filter traffic on the basis + /// of its source or destination host. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "value")] pub enum VpcFirewallRuleHostFilter { - #[doc = "The rule applies to traffic from/to all instances in the VPC"] + ///The rule applies to traffic from/to all instances in the VPC #[serde(rename = "vpc")] Vpc(Name), - #[doc = "The rule applies to traffic from/to all instances in the VPC Subnet"] + ///The rule applies to traffic from/to all instances in the VPC Subnet #[serde(rename = "subnet")] Subnet(Name), - #[doc = "The rule applies to traffic from/to this specific instance"] + ///The rule applies to traffic from/to this specific instance #[serde(rename = "instance")] Instance(Name), - #[doc = "The rule applies to traffic from/to a specific IP address"] + ///The rule applies to traffic from/to a specific IP address #[serde(rename = "ip")] Ip(String), - #[doc = "The rule applies to traffic from/to a specific IP subnet"] + ///The rule applies to traffic from/to a specific IP subnet #[serde(rename = "ip_net")] IpNet(IpNet), } - #[doc = "The protocols that may be specified in a firewall rule's filter"] + ///The protocols that may be specified in a firewall rule's filter #[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash)] pub enum VpcFirewallRuleProtocol { #[serde(rename = "TCP")] @@ -1472,89 +1573,94 @@ pub mod types { } } - #[doc = "A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to which a firewall rule applies."] + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to + /// which a firewall rule applies. #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(tag = "type", content = "value")] pub enum VpcFirewallRuleTarget { - #[doc = "The rule applies to all instances in the VPC"] + ///The rule applies to all instances in the VPC #[serde(rename = "vpc")] Vpc(Name), - #[doc = "The rule applies to all instances in the VPC Subnet"] + ///The rule applies to all instances in the VPC Subnet #[serde(rename = "subnet")] Subnet(Name), - #[doc = "The rule applies to this specific instance"] + ///The rule applies to this specific instance #[serde(rename = "instance")] Instance(Name), - #[doc = "The rule applies to a specific IP address"] + ///The rule applies to a specific IP address #[serde(rename = "ip")] Ip(String), - #[doc = "The rule applies to a specific IP subnet"] + ///The rule applies to a specific IP subnet #[serde(rename = "ip_net")] IpNet(IpNet), } - #[doc = "A single rule in a VPC firewall"] + ///A single rule in a VPC firewall #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcFirewallRuleUpdate { - #[doc = "whether traffic matching the rule should be allowed or dropped"] + ///whether traffic matching the rule should be allowed or dropped pub action: VpcFirewallRuleAction, - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "whether this rule is for incoming or outgoing traffic"] + ///whether this rule is for incoming or outgoing traffic pub direction: VpcFirewallRuleDirection, - #[doc = "reductions on the scope of the rule"] + ///reductions on the scope of the rule pub filters: VpcFirewallRuleFilter, - #[doc = "name of the rule, unique to this VPC"] + ///name of the rule, unique to this VPC pub name: Name, - #[doc = "the relative priority of this rule"] + ///the relative priority of this rule pub priority: u16, - #[doc = "whether this rule is in effect"] + ///whether this rule is in effect pub status: VpcFirewallRuleStatus, - #[doc = "list of sets of instances that the rule applies to"] + ///list of sets of instances that the rule applies to pub targets: Vec, } - #[doc = "Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules are implicitly created along with a Vpc, so there is no explicit creation."] + ///Updateable properties of a `Vpc`'s firewall Note that VpcFirewallRules + /// are implicitly created along with a Vpc, so there is no explicit + /// creation. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcFirewallRuleUpdateParams { pub rules: Vec, } - #[doc = "Collection of a [`Vpc`]'s firewall rules"] + ///Collection of a [`Vpc`]'s firewall rules #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcFirewallRules { pub rules: Vec, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "A VPC router defines a series of rules that indicate where traffic should be sent depending on its destination."] + ///A VPC router defines a series of rules that indicate where traffic + /// should be sent depending on its destination. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcRouter { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, pub kind: VpcRouterKind, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "The VPC to which the router belongs."] + ///The VPC to which the router belongs. pub vpc_id: uuid::Uuid, } - #[doc = "Create-time parameters for a [`VpcRouter`](crate::external_api::views::VpcRouter)"] + ///Create-time parameters for a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcRouterCreate { pub description: String, @@ -1578,17 +1684,18 @@ pub mod types { } } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcRouterResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Updateable properties of a [`VpcRouter`](crate::external_api::views::VpcRouter)"] + ///Updateable properties of a + /// [`VpcRouter`](crate::external_api::views::VpcRouter) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcRouterUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1597,50 +1704,62 @@ pub mod types { pub name: Option, } - #[doc = "A VPC subnet represents a logical grouping for instances that allows network traffic between them, within a IPv4 subnetwork or optionall an IPv6 subnetwork."] + ///A VPC subnet represents a logical grouping for instances that allows + /// network traffic between them, within a IPv4 subnetwork or optionall an + /// IPv6 subnetwork. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcSubnet { - #[doc = "human-readable free-form text about a resource"] + ///human-readable free-form text about a resource pub description: String, - #[doc = "unique, immutable, system-controlled identifier for each resource"] + ///unique, immutable, system-controlled identifier for each resource pub id: uuid::Uuid, - #[doc = "The IPv4 subnet CIDR block."] + ///The IPv4 subnet CIDR block. pub ipv4_block: Ipv4Net, - #[doc = "The IPv6 subnet CIDR block."] + ///The IPv6 subnet CIDR block. pub ipv6_block: Ipv6Net, - #[doc = "unique, mutable, user-controlled identifier for each resource"] + ///unique, mutable, user-controlled identifier for each resource pub name: Name, - #[doc = "timestamp when this resource was created"] + ///timestamp when this resource was created pub time_created: chrono::DateTime, - #[doc = "timestamp when this resource was last modified"] + ///timestamp when this resource was last modified pub time_modified: chrono::DateTime, - #[doc = "The VPC to which the subnet belongs."] + ///The VPC to which the subnet belongs. pub vpc_id: uuid::Uuid, } - #[doc = "Create-time parameters for a [`VpcSubnet`](crate::external_api::views::VpcSubnet)"] + ///Create-time parameters for a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcSubnetCreate { pub description: String, - #[doc = "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."] + ///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, - #[doc = "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."] + ///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 = "Option::is_none")] pub ipv6_block: Option, pub name: Name, } - #[doc = "A single page of results"] + ///A single page of results #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcSubnetResultsPage { - #[doc = "list of items on this page of results"] + ///list of items on this page of results pub items: Vec, - #[doc = "token used to fetch the next page of results (if any)"] + ///token used to fetch the next page of results (if any) #[serde(default, skip_serializing_if = "Option::is_none")] pub next_page: Option, } - #[doc = "Updateable properties of a [`VpcSubnet`](crate::external_api::views::VpcSubnet)"] + ///Updateable properties of a + /// [`VpcSubnet`](crate::external_api::views::VpcSubnet) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcSubnetUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1649,7 +1768,7 @@ pub mod types { pub name: Option, } - #[doc = "Updateable properties of a [`Vpc`](crate::external_api::views::Vpc)"] + ///Updateable properties of a [`Vpc`](crate::external_api::views::Vpc) #[derive(Serialize, Deserialize, Debug, Clone)] pub struct VpcUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1663,8 +1782,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -1692,8 +1811,18 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "List racks in the system\n\nSends a `GET` request to `/hardware/racks`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] +impl Client { + ///List racks in the system + /// + ///Sends a `GET` request to `/hardware/racks` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` pub async fn hardware_racks_get<'a>( &'a self, limit: Option, @@ -1729,7 +1858,14 @@ impl Client { } } - #[doc = "List racks in the system as a Stream\n\nSends repeated `GET` requests to `/hardware/racks` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List racks in the system as a Stream + /// + ///Sends repeated `GET` requests to `/hardware/racks` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` pub fn hardware_racks_get_stream<'a>( &'a self, limit: Option, @@ -1764,7 +1900,12 @@ impl Client { .boxed() } - #[doc = "Fetch information about a particular rack\n\nSends a `GET` request to `/hardware/racks/{rack_id}`\n\nArguments:\n- `rack_id`: The rack's unique ID.\n"] + ///Fetch information about a particular rack + /// + ///Sends a `GET` request to `/hardware/racks/{rack_id}` + /// + ///Arguments: + /// - `rack_id`: The rack's unique ID. pub async fn hardware_racks_get_rack<'a>( &'a self, rack_id: &'a uuid::Uuid, @@ -1772,7 +1913,7 @@ impl Client { let url = format!( "{}/hardware/racks/{}", self.baseurl, - progenitor_client::encode_path(&rack_id.to_string()), + encode_path(&rack_id.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -1789,7 +1930,15 @@ impl Client { } } - #[doc = "List sleds in the system\n\nSends a `GET` request to `/hardware/sleds`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List sleds in the system + /// + ///Sends a `GET` request to `/hardware/sleds` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` pub async fn hardware_sleds_get<'a>( &'a self, limit: Option, @@ -1825,7 +1974,14 @@ impl Client { } } - #[doc = "List sleds in the system as a Stream\n\nSends repeated `GET` requests to `/hardware/sleds` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List sleds in the system as a Stream + /// + ///Sends repeated `GET` requests to `/hardware/sleds` until there are no + /// more results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` pub fn hardware_sleds_get_stream<'a>( &'a self, limit: Option, @@ -1860,7 +2016,12 @@ impl Client { .boxed() } - #[doc = "Fetch information about a sled in the system\n\nSends a `GET` request to `/hardware/sleds/{sled_id}`\n\nArguments:\n- `sled_id`: The sled's unique ID.\n"] + ///Fetch information about a sled in the system + /// + ///Sends a `GET` request to `/hardware/sleds/{sled_id}` + /// + ///Arguments: + /// - `sled_id`: The sled's unique ID. pub async fn hardware_sleds_get_sled<'a>( &'a self, sled_id: &'a uuid::Uuid, @@ -1868,7 +2029,7 @@ impl Client { let url = format!( "{}/hardware/sleds/{}", self.baseurl, - progenitor_client::encode_path(&sled_id.to_string()), + encode_path(&sled_id.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -1885,7 +2046,18 @@ impl Client { } } - #[doc = "List global images\n\nReturns a list of all the global images. Global images are returned sorted by creation date, with the most recent images appearing first.\n\nSends a `GET` request to `/images`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List global images + /// + ///Returns a list of all the global images. Global images are returned + /// sorted by creation date, with the most recent images appearing first. + /// + ///Sends a `GET` request to `/images` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` pub async fn images_get<'a>( &'a self, limit: Option, @@ -1921,7 +2093,17 @@ impl Client { } } - #[doc = "List global images as a Stream\n\nReturns a list of all the global images. Global images are returned sorted by creation date, with the most recent images appearing first.\n\nSends repeated `GET` requests to `/images` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List global images as a Stream + /// + ///Returns a list of all the global images. Global images are returned + /// sorted by creation date, with the most recent images appearing first. + /// + ///Sends repeated `GET` requests to `/images` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` pub fn images_get_stream<'a>( &'a self, limit: Option, @@ -1957,13 +2139,18 @@ impl Client { .boxed() } - #[doc = "Create a global image\n\nCreate a new global image. This image can then be used by any user as a base for instances.\n\nSends a `POST` request to `/images`"] + ///Create a global image + /// + ///Create a new global image. This image can then be used by any user as a + /// base for instances. + /// + ///Sends a `POST` request to `/images` pub async fn images_post<'a>( &'a self, body: &'a types::ImageCreate, ) -> Result, Error> { let url = format!("{}/images", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -1978,7 +2165,11 @@ impl Client { } } - #[doc = "Get a global image\n\nReturns the details of a specific global image.\n\nSends a `GET` request to `/images/{image_name}`"] + ///Get a global image + /// + ///Returns the details of a specific global image. + /// + ///Sends a `GET` request to `/images/{image_name}` pub async fn images_get_image<'a>( &'a self, image_name: &'a types::Name, @@ -1986,7 +2177,7 @@ impl Client { let url = format!( "{}/images/{}", self.baseurl, - progenitor_client::encode_path(&image_name.to_string()), + encode_path(&image_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2003,7 +2194,13 @@ impl Client { } } - #[doc = "Delete a global image\n\nPermanently delete a global image. This operation cannot be undone. Any instances using the global image will continue to run, however new instances can not be created with this image.\n\nSends a `DELETE` request to `/images/{image_name}`"] + ///Delete a global image + /// + ///Permanently delete a global image. This operation cannot be undone. Any + /// instances using the global image will continue to run, however new + /// instances can not be created with this image. + /// + ///Sends a `DELETE` request to `/images/{image_name}` pub async fn images_delete_image<'a>( &'a self, image_name: &'a types::Name, @@ -2011,7 +2208,7 @@ impl Client { let url = format!( "{}/images/{}", self.baseurl, - progenitor_client::encode_path(&image_name.to_string()), + encode_path(&image_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2028,13 +2225,13 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/login`"] + ///Sends a `POST` request to `/login` pub async fn spoof_login<'a>( &'a self, body: &'a types::LoginParams, ) -> Result, Error> { let url = format!("{}/login", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2043,7 +2240,7 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/logout`"] + ///Sends a `POST` request to `/logout` pub async fn logout<'a>(&'a self) -> Result, Error> { let url = format!("{}/logout", self.baseurl,); let request = self.client.post(url).build()?; @@ -2055,7 +2252,15 @@ impl Client { } } - #[doc = "List all organizations\n\nSends a `GET` request to `/organizations`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List all organizations + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn organizations_get<'a>( &'a self, limit: Option, @@ -2091,7 +2296,14 @@ impl Client { } } - #[doc = "List all organizations as a Stream\n\nSends repeated `GET` requests to `/organizations` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List all organizations as a Stream + /// + ///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 organizations_get_stream<'a>( &'a self, limit: Option, @@ -2127,13 +2339,15 @@ impl Client { .boxed() } - #[doc = "Create a new organization\n\nSends a `POST` request to `/organizations`"] + ///Create a new organization + /// + ///Sends a `POST` request to `/organizations` pub async fn organizations_post<'a>( &'a self, body: &'a types::OrganizationCreate, ) -> Result, Error> { let url = format!("{}/organizations", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2148,7 +2362,12 @@ impl Client { } } - #[doc = "Fetch a specific organization\n\nSends a `GET` request to `/organizations/{organization_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n"] + ///Fetch a specific organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. pub async fn organizations_get_organization<'a>( &'a self, organization_name: &'a types::Name, @@ -2156,7 +2375,7 @@ impl Client { let url = format!( "{}/organizations/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2173,7 +2392,13 @@ impl Client { } } - #[doc = "Update a specific organization\n\nSends a `PUT` request to `/organizations/{organization_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `body`\n"] + ///Update a specific organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` pub async fn organizations_put_organization<'a>( &'a self, organization_name: &'a types::Name, @@ -2182,9 +2407,9 @@ impl Client { let url = format!( "{}/organizations/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2199,7 +2424,12 @@ impl Client { } } - #[doc = "Delete a specific organization\n\nSends a `DELETE` request to `/organizations/{organization_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n"] + ///Delete a specific organization + /// + ///Sends a `DELETE` request to `/organizations/{organization_name}` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. pub async fn organizations_delete_organization<'a>( &'a self, organization_name: &'a types::Name, @@ -2207,7 +2437,7 @@ impl Client { let url = format!( "{}/organizations/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2224,7 +2454,12 @@ impl Client { } } - #[doc = "Fetch the IAM policy for this Organization\n\nSends a `GET` request to `/organizations/{organization_name}/policy`\n\nArguments:\n- `organization_name`: The organization's unique name.\n"] + ///Fetch the IAM policy for this Organization + /// + ///Sends a `GET` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. pub async fn organization_get_policy<'a>( &'a self, organization_name: &'a types::Name, @@ -2232,7 +2467,7 @@ impl Client { let url = format!( "{}/organizations/{}/policy", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2249,7 +2484,13 @@ impl Client { } } - #[doc = "Update the IAM policy for this Organization\n\nSends a `PUT` request to `/organizations/{organization_name}/policy`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `body`\n"] + ///Update the IAM policy for this Organization + /// + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` pub async fn organization_put_policy<'a>( &'a self, organization_name: &'a types::Name, @@ -2258,9 +2499,9 @@ impl Client { let url = format!( "{}/organizations/{}/policy", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2275,7 +2516,16 @@ impl Client { } } - #[doc = "List all projects\n\nSends a `GET` request to `/organizations/{organization_name}/projects`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List all projects + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn organization_projects_get<'a>( &'a self, organization_name: &'a types::Name, @@ -2286,7 +2536,7 @@ impl Client { let url = format!( "{}/organizations/{}/projects", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -2316,7 +2566,16 @@ impl Client { } } - #[doc = "List all projects as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List all projects as a Stream + /// + ///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 organization_projects_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -2357,7 +2616,13 @@ impl Client { .boxed() } - #[doc = "Create a new project\n\nSends a `POST` request to `/organizations/{organization_name}/projects`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `body`\n"] + ///Create a new project + /// + ///Sends a `POST` request to `/organizations/{organization_name}/projects` + /// + ///Arguments: + /// - `organization_name`: The organization's unique name. + /// - `body` pub async fn organization_projects_post<'a>( &'a self, organization_name: &'a types::Name, @@ -2366,9 +2631,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), + encode_path(&organization_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2383,7 +2648,14 @@ impl Client { } } - #[doc = "Fetch a specific project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n"] + ///Fetch a specific project + /// + ///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 organization_projects_get_project<'a>( &'a self, organization_name: &'a types::Name, @@ -2392,8 +2664,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2410,7 +2682,15 @@ impl Client { } } - #[doc = "Update a specific project\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Update a specific project + /// + ///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 organization_projects_put_project<'a>( &'a self, organization_name: &'a types::Name, @@ -2420,10 +2700,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2438,7 +2718,14 @@ impl Client { } } - #[doc = "Delete a specific project\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n"] + ///Delete a specific project + /// + ///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 organization_projects_delete_project<'a>( &'a self, organization_name: &'a types::Name, @@ -2447,8 +2734,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2465,7 +2752,18 @@ impl Client { } } - #[doc = "List disks in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/disks`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List disks in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn project_disks_get<'a>( &'a self, organization_name: &'a types::Name, @@ -2477,8 +2775,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/disks", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -2508,7 +2806,17 @@ impl Client { } } - #[doc = "List disks in a project as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/disks` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List disks in a project as a Stream + /// + ///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 project_disks_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -2551,7 +2859,15 @@ impl Client { .boxed() } - #[doc = "Create a disk in a project\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/disks`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Create a disk in a project + /// + ///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 project_disks_post<'a>( &'a self, organization_name: &'a types::Name, @@ -2561,10 +2877,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/disks", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2579,7 +2895,11 @@ impl Client { } } - #[doc = "Fetch a single disk in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/disks/{disk_name}`"] + ///Fetch a single disk in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` pub async fn project_disks_get_disk<'a>( &'a self, organization_name: &'a types::Name, @@ -2589,9 +2909,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/disks/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&disk_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2608,7 +2928,11 @@ impl Client { } } - #[doc = "Delete a disk from a project\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/disks/{disk_name}`"] + ///Delete a disk from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/disks/ + /// {disk_name}` pub async fn project_disks_delete_disk<'a>( &'a self, organization_name: &'a types::Name, @@ -2618,9 +2942,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/disks/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&disk_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&disk_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2637,7 +2961,21 @@ impl Client { } } - #[doc = "List images\n\nList images in a project. The images are returned sorted by creation date, with the most recent images appearing first.\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/images`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn project_images_get<'a>( &'a self, organization_name: &'a types::Name, @@ -2649,8 +2987,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/images", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -2680,7 +3018,20 @@ impl Client { } } - #[doc = "List images as a Stream\n\nList images in a project. The images are returned sorted by creation date, with the most recent images appearing first.\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/images` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///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 project_images_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -2723,7 +3074,17 @@ impl Client { .boxed() } - #[doc = "Create an image\n\nCreate a new image in a project.\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/images`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///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 project_images_post<'a>( &'a self, organization_name: &'a types::Name, @@ -2733,10 +3094,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/images", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2751,7 +3112,13 @@ impl Client { } } - #[doc = "Get an image\n\nGet the details of a specific image in a project.\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/images/{image_name}`"] + ///Get an image + /// + ///Get the details of a specific image in a project. + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/images/ + /// {image_name}` pub async fn project_images_get_image<'a>( &'a self, organization_name: &'a types::Name, @@ -2761,9 +3128,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/images/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&image_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2780,7 +3147,15 @@ impl Client { } } - #[doc = "Delete an image\n\nPermanently 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.\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/images/{image_name}`"] + ///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 project_images_delete_image<'a>( &'a self, organization_name: &'a types::Name, @@ -2790,9 +3165,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/images/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&image_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&image_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2809,7 +3184,18 @@ impl Client { } } - #[doc = "List instances in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/instances`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List instances in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn project_instances_get<'a>( &'a self, organization_name: &'a types::Name, @@ -2821,8 +3207,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -2852,7 +3238,17 @@ impl Client { } } - #[doc = "List instances in a project as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/instances` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List instances in a project 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 project_instances_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -2896,7 +3292,15 @@ impl Client { .boxed() } - #[doc = "Create an instance in a project\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Create an instance in a project + /// + ///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 project_instances_post<'a>( &'a self, organization_name: &'a types::Name, @@ -2906,10 +3310,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -2924,7 +3328,11 @@ impl Client { } } - #[doc = "Get an instance in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}`"] + ///Get an instance in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` pub async fn project_instances_get_instance<'a>( &'a self, organization_name: &'a types::Name, @@ -2934,9 +3342,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -2953,7 +3361,11 @@ impl Client { } } - #[doc = "Delete an instance from a project\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}`"] + ///Delete an instance from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}` pub async fn project_instances_delete_instance<'a>( &'a self, organization_name: &'a types::Name, @@ -2963,9 +3375,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -2982,7 +3394,20 @@ impl Client { } } - #[doc = "List disks attached to this instance\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `instance_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List disks attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn instance_disks_get<'a>( &'a self, organization_name: &'a types::Name, @@ -2995,9 +3420,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -3027,7 +3452,18 @@ impl Client { } } - #[doc = "List disks attached to this instance as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `instance_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List disks attached to this instance as a Stream + /// + ///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_disks_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -3079,7 +3515,9 @@ impl Client { .boxed() } - #[doc = "Sends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks/attach`"] + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/attach` pub async fn instance_disks_attach<'a>( &'a self, organization_name: &'a types::Name, @@ -3090,11 +3528,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/attach", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3109,7 +3547,9 @@ impl Client { } } - #[doc = "Sends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/disks/detach`"] + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/disks/detach` pub async fn instance_disks_detach<'a>( &'a self, organization_name: &'a types::Name, @@ -3120,11 +3560,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/detach", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3139,7 +3579,12 @@ impl Client { } } - #[doc = "Migrate an instance to a different propolis-server, possibly on a different sled\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/migrate`"] + ///Migrate an instance to a different propolis-server, possibly on a + /// different sled + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/migrate` pub async fn project_instances_migrate_instance<'a>( &'a self, organization_name: &'a types::Name, @@ -3150,11 +3595,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/migrate", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3169,7 +3614,20 @@ impl Client { } } - #[doc = "List network interfaces attached to this instance\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `instance_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List network interfaces attached to this instance + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn instance_network_interfaces_get<'a>( &'a self, organization_name: &'a types::Name, @@ -3182,9 +3640,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -3214,7 +3672,18 @@ impl Client { } } - #[doc = "List network interfaces attached to this instance as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `instance_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List network interfaces attached to this instance 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_interfaces_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -3267,7 +3736,11 @@ impl Client { .boxed() } - #[doc = "Create a network interface for an instance\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces`"] + ///Create a network interface for an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces` pub async fn instance_network_interfaces_post<'a>( &'a self, organization_name: &'a types::Name, @@ -3278,11 +3751,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3297,7 +3770,11 @@ impl Client { } } - #[doc = "Get an interface attached to an instance\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces/{interface_name}`"] + ///Get an interface attached to an instance + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` pub async fn instance_network_interfaces_get_interface<'a>( &'a self, organization_name: &'a types::Name, @@ -3308,10 +3785,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), - progenitor_client::encode_path(&interface_name.to_string()), + 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 = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -3328,7 +3805,11 @@ impl Client { } } - #[doc = "Detach a network interface from an instance\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/network-interfaces/{interface_name}`"] + ///Detach a network interface from an instance + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/network-interfaces/{interface_name}` pub async fn instance_network_interfaces_delete_interface<'a>( &'a self, organization_name: &'a types::Name, @@ -3339,10 +3820,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), - progenitor_client::encode_path(&interface_name.to_string()), + 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 = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -3359,7 +3840,11 @@ impl Client { } } - #[doc = "Reboot an instance\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/reboot`"] + ///Reboot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/reboot` pub async fn project_instances_instance_reboot<'a>( &'a self, organization_name: &'a types::Name, @@ -3369,9 +3854,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/reboot", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let request = self.client.post(url).build()?; let result = self.client.execute(request).await; @@ -3388,7 +3873,11 @@ impl Client { } } - #[doc = "Boot an instance\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/start`"] + ///Boot an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/start` pub async fn project_instances_instance_start<'a>( &'a self, organization_name: &'a types::Name, @@ -3398,9 +3887,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/start", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let request = self.client.post(url).build()?; let result = self.client.execute(request).await; @@ -3417,7 +3906,11 @@ impl Client { } } - #[doc = "Halt an instance\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/instances/{instance_name}/stop`"] + ///Halt an instance + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/instances/ + /// {instance_name}/stop` pub async fn project_instances_instance_stop<'a>( &'a self, organization_name: &'a types::Name, @@ -3427,9 +3920,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/instances/{}/stop", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&instance_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&instance_name.to_string()), ); let request = self.client.post(url).build()?; let result = self.client.execute(request).await; @@ -3446,7 +3939,14 @@ impl Client { } } - #[doc = "Fetch the IAM policy for this Project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/policy`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n"] + ///Fetch the IAM policy for this Project + /// + ///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 organization_projects_get_project_policy<'a>( &'a self, organization_name: &'a types::Name, @@ -3455,8 +3955,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/policy", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -3473,7 +3973,15 @@ impl Client { } } - #[doc = "Update the IAM policy for this Project\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/policy`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Update the IAM policy for this Project + /// + ///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 organization_projects_put_project_policy<'a>( &'a self, organization_name: &'a types::Name, @@ -3483,10 +3991,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/policy", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3501,7 +4009,18 @@ impl Client { } } - #[doc = "List snapshots in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/snapshots`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List snapshots in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn project_snapshots_get<'a>( &'a self, organization_name: &'a types::Name, @@ -3513,8 +4032,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/snapshots", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -3544,7 +4063,17 @@ impl Client { } } - #[doc = "List snapshots in a project as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/snapshots` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List snapshots in a project 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 project_snapshots_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -3588,7 +4117,15 @@ impl Client { .boxed() } - #[doc = "Create a snapshot of a disk\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/snapshots`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Create a snapshot of 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 project_snapshots_post<'a>( &'a self, organization_name: &'a types::Name, @@ -3598,10 +4135,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/snapshots", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3616,7 +4153,11 @@ impl Client { } } - #[doc = "Get a snapshot in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/snapshots/{snapshot_name}`"] + ///Get a snapshot in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` pub async fn project_snapshots_get_snapshot<'a>( &'a self, organization_name: &'a types::Name, @@ -3626,9 +4167,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/snapshots/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&snapshot_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -3645,7 +4186,11 @@ impl Client { } } - #[doc = "Delete a snapshot from a project\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/snapshots/{snapshot_name}`"] + ///Delete a snapshot from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/snapshots/ + /// {snapshot_name}` pub async fn project_snapshots_delete_snapshot<'a>( &'a self, organization_name: &'a types::Name, @@ -3655,9 +4200,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/snapshots/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&snapshot_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&snapshot_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -3674,7 +4219,18 @@ impl Client { } } - #[doc = "List VPCs in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List VPCs in a project + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn project_vpcs_get<'a>( &'a self, organization_name: &'a types::Name, @@ -3686,8 +4242,8 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -3717,7 +4273,17 @@ impl Client { } } - #[doc = "List VPCs in a project as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/vpcs` until there are no more results.\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List VPCs in a project 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 project_vpcs_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -3760,7 +4326,15 @@ impl Client { .boxed() } - #[doc = "Create a VPC in a project\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/vpcs`\n\nArguments:\n- `organization_name`: The organization's unique name.\n- `project_name`: The project's unique name within the organization.\n- `body`\n"] + ///Create a VPC in a project + /// + ///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 project_vpcs_post<'a>( &'a self, organization_name: &'a types::Name, @@ -3770,10 +4344,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3788,7 +4362,11 @@ impl Client { } } - #[doc = "Get a VPC in a project\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}`"] + ///Get a VPC in a project + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` pub async fn project_vpcs_get_vpc<'a>( &'a self, organization_name: &'a types::Name, @@ -3798,9 +4376,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -3817,7 +4395,11 @@ impl Client { } } - #[doc = "Update a VPC\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}`"] + ///Update a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` pub async fn project_vpcs_put_vpc<'a>( &'a self, organization_name: &'a types::Name, @@ -3828,11 +4410,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3847,7 +4429,11 @@ impl Client { } } - #[doc = "Delete a vpc from a project\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}`"] + ///Delete a vpc from a project + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}` pub async fn project_vpcs_delete_vpc<'a>( &'a self, organization_name: &'a types::Name, @@ -3857,9 +4443,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -3876,7 +4462,11 @@ impl Client { } } - #[doc = "List firewall rules for a VPC\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/firewall/rules`"] + ///List firewall rules for a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` pub async fn vpc_firewall_rules_get<'a>( &'a self, organization_name: &'a types::Name, @@ -3886,9 +4476,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -3905,7 +4495,11 @@ impl Client { } } - #[doc = "Replace the firewall rules for a VPC\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/firewall/rules`"] + ///Replace the firewall rules for a VPC + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/firewall/rules` pub async fn vpc_firewall_rules_put<'a>( &'a self, organization_name: &'a types::Name, @@ -3916,11 +4510,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -3935,7 +4529,20 @@ impl Client { } } - #[doc = "List VPC Custom and System Routers\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List VPC Custom and System 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 retreive the + /// subsequent page + /// - `sort_by` pub async fn vpc_routers_get<'a>( &'a self, organization_name: &'a types::Name, @@ -3948,9 +4555,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -3980,7 +4587,18 @@ impl Client { } } - #[doc = "List VPC Custom and System Routers as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List VPC Custom and System 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_routers_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -4033,7 +4651,11 @@ impl Client { .boxed() } - #[doc = "Create a VPC Router\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers`"] + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers` pub async fn vpc_routers_post<'a>( &'a self, organization_name: &'a types::Name, @@ -4044,11 +4666,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4063,7 +4685,11 @@ impl Client { } } - #[doc = "Get a VPC Router\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}`"] + ///Get a VPC Router + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` pub async fn vpc_routers_get_router<'a>( &'a self, organization_name: &'a types::Name, @@ -4074,10 +4700,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), + 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 = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -4094,7 +4720,11 @@ impl Client { } } - #[doc = "Update a VPC Router\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}`"] + ///Update a VPC Router + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` pub async fn vpc_routers_put_router<'a>( &'a self, organization_name: &'a types::Name, @@ -4106,12 +4736,12 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), + 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 = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4126,7 +4756,11 @@ impl Client { } } - #[doc = "Delete a router from its VPC\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}`"] + ///Delete a router from its VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}` pub async fn vpc_routers_delete_router<'a>( &'a self, organization_name: &'a types::Name, @@ -4137,10 +4771,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), + 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 = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -4157,7 +4791,21 @@ impl Client { } } - #[doc = "List a Router's routes\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `router_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List a Router's routes + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn routers_routes_get<'a>( &'a self, organization_name: &'a types::Name, @@ -4171,10 +4819,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), + 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 mut query = Vec::new(); if let Some(v) = &limit { @@ -4204,7 +4852,20 @@ impl Client { } } - #[doc = "List a Router's routes as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `router_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List a Router's routes as a Stream + /// + ///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 routers_routes_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -4260,7 +4921,11 @@ impl Client { .boxed() } - #[doc = "Create a VPC Router\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes`"] + ///Create a VPC Router + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes` pub async fn routers_routes_post<'a>( &'a self, organization_name: &'a types::Name, @@ -4272,12 +4937,12 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), + 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 = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4292,7 +4957,11 @@ impl Client { } } - #[doc = "Get a VPC Router route\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes/{route_name}`"] + ///Get a VPC Router route + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` pub async fn routers_routes_get_route<'a>( &'a self, organization_name: &'a types::Name, @@ -4304,11 +4973,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), - progenitor_client::encode_path(&route_name.to_string()), + 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 = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -4325,7 +4994,11 @@ impl Client { } } - #[doc = "Update a Router route\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes/{route_name}`"] + ///Update a Router route + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` pub async fn routers_routes_put_route<'a>( &'a self, organization_name: &'a types::Name, @@ -4338,13 +5011,13 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), - progenitor_client::encode_path(&route_name.to_string()), + 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 = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4359,7 +5032,11 @@ impl Client { } } - #[doc = "Delete a route from its router\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/routers/{router_name}/routes/{route_name}`"] + ///Delete a route from its router + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/routers/{router_name}/routes/{route_name}` pub async fn routers_routes_delete_route<'a>( &'a self, organization_name: &'a types::Name, @@ -4371,11 +5048,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&router_name.to_string()), - progenitor_client::encode_path(&route_name.to_string()), + 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 = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -4392,7 +5069,20 @@ impl Client { } } - #[doc = "List subnets in a VPC\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List subnets in a VPC + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn vpc_subnets_get<'a>( &'a self, organization_name: &'a types::Name, @@ -4405,9 +5095,9 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); let mut query = Vec::new(); if let Some(v) = &limit { @@ -4437,7 +5127,18 @@ impl Client { } } - #[doc = "List subnets in a VPC as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List subnets in a VPC 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_subnets_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -4490,7 +5191,11 @@ impl Client { .boxed() } - #[doc = "Create a subnet in a VPC\n\nSends a `POST` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets`"] + ///Create a subnet in a VPC + /// + ///Sends a `POST` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets` pub async fn vpc_subnets_post<'a>( &'a self, organization_name: &'a types::Name, @@ -4501,11 +5206,11 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), + encode_path(&organization_name.to_string()), + encode_path(&project_name.to_string()), + encode_path(&vpc_name.to_string()), ); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4520,7 +5225,11 @@ impl Client { } } - #[doc = "Get subnet in a VPC\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets/{subnet_name}`"] + ///Get subnet in a VPC + /// + ///Sends a `GET` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` pub async fn vpc_subnets_get_subnet<'a>( &'a self, organization_name: &'a types::Name, @@ -4531,10 +5240,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&subnet_name.to_string()), + 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 = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -4551,7 +5260,11 @@ impl Client { } } - #[doc = "Update a VPC Subnet\n\nSends a `PUT` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets/{subnet_name}`"] + ///Update a VPC Subnet + /// + ///Sends a `PUT` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` pub async fn vpc_subnets_put_subnet<'a>( &'a self, organization_name: &'a types::Name, @@ -4563,12 +5276,12 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&subnet_name.to_string()), + 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 = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4583,7 +5296,11 @@ impl Client { } } - #[doc = "Delete a subnet from a VPC\n\nSends a `DELETE` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets/{subnet_name}`"] + ///Delete a subnet from a VPC + /// + ///Sends a `DELETE` request to + /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ + /// {vpc_name}/subnets/{subnet_name}` pub async fn vpc_subnets_delete_subnet<'a>( &'a self, organization_name: &'a types::Name, @@ -4594,10 +5311,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&subnet_name.to_string()), + 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 = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -4614,7 +5331,21 @@ impl Client { } } - #[doc = "List network interfaces in a VPC subnet\n\nSends a `GET` request to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets/{subnet_name}/network-interfaces`\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `subnet_name`\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List network interfaces in a VPC subnet + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn subnet_network_interfaces_get<'a>( &'a self, organization_name: &'a types::Name, @@ -4628,10 +5359,10 @@ impl Client { let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}/network-interfaces", self.baseurl, - progenitor_client::encode_path(&organization_name.to_string()), - progenitor_client::encode_path(&project_name.to_string()), - progenitor_client::encode_path(&vpc_name.to_string()), - progenitor_client::encode_path(&subnet_name.to_string()), + 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 mut query = Vec::new(); if let Some(v) = &limit { @@ -4661,7 +5392,20 @@ impl Client { } } - #[doc = "List network interfaces in a VPC subnet as a Stream\n\nSends repeated `GET` requests to `/organizations/{organization_name}/projects/{project_name}/vpcs/{vpc_name}/subnets/{subnet_name}/network-interfaces` until there are no more results.\n\nArguments:\n- `organization_name`\n- `project_name`\n- `vpc_name`\n- `subnet_name`\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List network interfaces in a VPC subnet 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 subnet_network_interfaces_get_stream<'a>( &'a self, organization_name: &'a types::Name, @@ -4717,7 +5461,9 @@ impl Client { .boxed() } - #[doc = "Fetch the top-level IAM policy\n\nSends a `GET` request to `/policy`"] + ///Fetch the top-level IAM policy + /// + ///Sends a `GET` request to `/policy` pub async fn policy_get<'a>( &'a self, ) -> Result, Error> { @@ -4737,13 +5483,15 @@ impl Client { } } - #[doc = "Update the top-level IAM policy\n\nSends a `PUT` request to `/policy`"] + ///Update the top-level IAM policy + /// + ///Sends a `PUT` request to `/policy` pub async fn policy_put<'a>( &'a self, body: &'a types::FleetRolesPolicy, ) -> Result, Error> { let url = format!("{}/policy", self.baseurl,); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -4758,7 +5506,14 @@ impl Client { } } - #[doc = "List the built-in roles\n\nSends a `GET` request to `/roles`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n"] + ///List the 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 retreive the + /// subsequent page pub async fn roles_get<'a>( &'a self, limit: Option, @@ -4789,7 +5544,13 @@ impl Client { } } - #[doc = "List the built-in roles as a Stream\n\nSends repeated `GET` requests to `/roles` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n"] + ///List the 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 roles_get_stream<'a>( &'a self, limit: Option, @@ -4823,7 +5584,12 @@ impl Client { .boxed() } - #[doc = "Fetch a specific built-in role\n\nSends a `GET` request to `/roles/{role_name}`\n\nArguments:\n- `role_name`: The built-in role's unique name.\n"] + ///Fetch a specific built-in role + /// + ///Sends a `GET` request to `/roles/{role_name}` + /// + ///Arguments: + /// - `role_name`: The built-in role's unique name. pub async fn roles_get_role<'a>( &'a self, role_name: &'a str, @@ -4831,7 +5597,7 @@ impl Client { let url = format!( "{}/roles/{}", self.baseurl, - progenitor_client::encode_path(&role_name.to_string()), + encode_path(&role_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -4848,7 +5614,15 @@ impl Client { } } - #[doc = "List all sagas (for debugging)\n\nSends a `GET` request to `/sagas`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List all sagas (for debugging) + /// + ///Sends a `GET` request to `/sagas` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` pub async fn sagas_get<'a>( &'a self, limit: Option, @@ -4884,7 +5658,14 @@ impl Client { } } - #[doc = "List all sagas (for debugging) as a Stream\n\nSends repeated `GET` requests to `/sagas` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List all sagas (for debugging) as a Stream + /// + ///Sends repeated `GET` requests to `/sagas` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` pub fn sagas_get_stream<'a>( &'a self, limit: Option, @@ -4919,7 +5700,9 @@ impl Client { .boxed() } - #[doc = "Fetch information about a single saga (for debugging)\n\nSends a `GET` request to `/sagas/{saga_id}`"] + ///Fetch information about a single saga (for debugging) + /// + ///Sends a `GET` request to `/sagas/{saga_id}` pub async fn sagas_get_saga<'a>( &'a self, saga_id: &'a uuid::Uuid, @@ -4927,7 +5710,7 @@ impl Client { let url = format!( "{}/sagas/{}", self.baseurl, - progenitor_client::encode_path(&saga_id.to_string()), + encode_path(&saga_id.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -4944,7 +5727,9 @@ impl Client { } } - #[doc = "Fetch the user associated with the current session\n\nSends a `GET` request to `/session/me`"] + ///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> { @@ -4964,7 +5749,15 @@ impl Client { } } - #[doc = "List the current user's SSH public keys\n\nSends a `GET` request to `/session/me/sshkeys`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List the current user's SSH public keys + /// + ///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 retreive the + /// subsequent page + /// - `sort_by` pub async fn sshkeys_get<'a>( &'a self, limit: Option, @@ -5000,7 +5793,14 @@ impl Client { } } - #[doc = "List the current user's SSH public keys as a Stream\n\nSends repeated `GET` requests to `/session/me/sshkeys` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List the current user's SSH public keys as a Stream + /// + ///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 sshkeys_get_stream<'a>( &'a self, limit: Option, @@ -5035,13 +5835,15 @@ impl Client { .boxed() } - #[doc = "Create a new SSH public key for the current user\n\nSends a `POST` request to `/session/me/sshkeys`"] + ///Create a new SSH public key for the current user + /// + ///Sends a `POST` request to `/session/me/sshkeys` pub async fn sshkeys_post<'a>( &'a self, body: &'a types::SshKeyCreate, ) -> Result, Error> { let url = format!("{}/session/me/sshkeys", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -5056,7 +5858,9 @@ impl Client { } } - #[doc = "Get (by name) an SSH public key belonging to the current user\n\nSends a `GET` request to `/session/me/sshkeys/{ssh_key_name}`"] + ///Get (by name) an SSH public key belonging to the current user + /// + ///Sends a `GET` request to `/session/me/sshkeys/{ssh_key_name}` pub async fn sshkeys_get_key<'a>( &'a self, ssh_key_name: &'a types::Name, @@ -5064,7 +5868,7 @@ impl Client { let url = format!( "{}/session/me/sshkeys/{}", self.baseurl, - progenitor_client::encode_path(&ssh_key_name.to_string()), + encode_path(&ssh_key_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -5081,7 +5885,9 @@ impl Client { } } - #[doc = "Delete (by name) an SSH public key belonging to the current user\n\nSends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}`"] + ///Delete (by name) an SSH public key belonging to the current user + /// + ///Sends a `DELETE` request to `/session/me/sshkeys/{ssh_key_name}` pub async fn sshkeys_delete_key<'a>( &'a self, ssh_key_name: &'a types::Name, @@ -5089,7 +5895,7 @@ impl Client { let url = format!( "{}/session/me/sshkeys/{}", self.baseurl, - progenitor_client::encode_path(&ssh_key_name.to_string()), + encode_path(&ssh_key_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -5106,7 +5912,13 @@ impl Client { } } - #[doc = "Sends a `GET` request to `/silos`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///Sends a `GET` request to `/silos` + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retreive the + /// subsequent page + /// - `sort_by` pub async fn silos_get<'a>( &'a self, limit: Option, @@ -5142,7 +5954,12 @@ impl Client { } } - #[doc = "Sends repeated `GET` requests to `/silos` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///Sends repeated `GET` requests to `/silos` until there are no more + /// results. + /// + ///Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `sort_by` pub fn silos_get_stream<'a>( &'a self, limit: Option, @@ -5177,13 +5994,15 @@ impl Client { .boxed() } - #[doc = "Create a new silo\n\nSends a `POST` request to `/silos`"] + ///Create a new silo + /// + ///Sends a `POST` request to `/silos` pub async fn silos_post<'a>( &'a self, body: &'a types::SiloCreate, ) -> Result, Error> { let url = format!("{}/silos", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -5198,7 +6017,12 @@ impl Client { } } - #[doc = "Fetch a specific silo\n\nSends a `GET` request to `/silos/{silo_name}`\n\nArguments:\n- `silo_name`: The silo's unique name.\n"] + ///Fetch a specific silo + /// + ///Sends a `GET` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. pub async fn silos_get_silo<'a>( &'a self, silo_name: &'a types::Name, @@ -5206,7 +6030,7 @@ impl Client { let url = format!( "{}/silos/{}", self.baseurl, - progenitor_client::encode_path(&silo_name.to_string()), + encode_path(&silo_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -5223,7 +6047,12 @@ impl Client { } } - #[doc = "Delete a specific silo\n\nSends a `DELETE` request to `/silos/{silo_name}`\n\nArguments:\n- `silo_name`: The silo's unique name.\n"] + ///Delete a specific silo + /// + ///Sends a `DELETE` request to `/silos/{silo_name}` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. pub async fn silos_delete_silo<'a>( &'a self, silo_name: &'a types::Name, @@ -5231,7 +6060,7 @@ impl Client { let url = format!( "{}/silos/{}", self.baseurl, - progenitor_client::encode_path(&silo_name.to_string()), + encode_path(&silo_name.to_string()), ); let request = self.client.delete(url).build()?; let result = self.client.execute(request).await; @@ -5248,7 +6077,12 @@ impl Client { } } - #[doc = "Fetch the IAM policy for this Silo\n\nSends a `GET` request to `/silos/{silo_name}/policy`\n\nArguments:\n- `silo_name`: The silo's unique name.\n"] + ///Fetch the IAM policy for this Silo + /// + ///Sends a `GET` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. pub async fn silos_get_silo_policy<'a>( &'a self, silo_name: &'a types::Name, @@ -5256,7 +6090,7 @@ impl Client { let url = format!( "{}/silos/{}/policy", self.baseurl, - progenitor_client::encode_path(&silo_name.to_string()), + encode_path(&silo_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; @@ -5273,7 +6107,13 @@ impl Client { } } - #[doc = "Update the IAM policy for this Silo\n\nSends a `PUT` request to `/silos/{silo_name}/policy`\n\nArguments:\n- `silo_name`: The silo's unique name.\n- `body`\n"] + ///Update the IAM policy for this Silo + /// + ///Sends a `PUT` request to `/silos/{silo_name}/policy` + /// + ///Arguments: + /// - `silo_name`: The silo's unique name. + /// - `body` pub async fn silos_put_silo_policy<'a>( &'a self, silo_name: &'a types::Name, @@ -5282,9 +6122,9 @@ impl Client { let url = format!( "{}/silos/{}/policy", self.baseurl, - progenitor_client::encode_path(&silo_name.to_string()), + encode_path(&silo_name.to_string()), ); - let request = self.client.put(url).json(body).build()?; + let request = self.client.put(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { @@ -5299,7 +6139,14 @@ impl Client { } } - #[doc = "List all timeseries schema\n\nSends a `GET` request to `/timeseries/schema`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n"] + ///List all 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 retreive the + /// subsequent page pub async fn timeseries_schema_get<'a>( &'a self, limit: Option, @@ -5330,7 +6177,13 @@ impl Client { } } - #[doc = "List all timeseries schema as a Stream\n\nSends repeated `GET` requests to `/timeseries/schema` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n"] + ///List all 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, @@ -5365,7 +6218,9 @@ impl Client { .boxed() } - #[doc = "Refresh update metadata\n\nSends a `POST` request to `/updates/refresh`"] + ///Refresh update metadata + /// + ///Sends a `POST` request to `/updates/refresh` pub async fn updates_refresh<'a>(&'a self) -> Result, Error> { let url = format!("{}/updates/refresh", self.baseurl,); let request = self.client.post(url).build()?; @@ -5383,7 +6238,15 @@ impl Client { } } - #[doc = "List the built-in system users\n\nSends a `GET` request to `/users`\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `page_token`: Token returned by previous call to retreive the subsequent page\n- `sort_by`\n"] + ///List the built-in system 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 retreive the + /// subsequent page + /// - `sort_by` pub async fn users_get<'a>( &'a self, limit: Option, @@ -5419,7 +6282,14 @@ impl Client { } } - #[doc = "List the built-in system users as a Stream\n\nSends repeated `GET` requests to `/users` until there are no more results.\n\nArguments:\n- `limit`: Maximum number of items returned by a single call\n- `sort_by`\n"] + ///List the built-in system 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 users_get_stream<'a>( &'a self, limit: Option, @@ -5454,7 +6324,12 @@ impl Client { .boxed() } - #[doc = "Fetch a specific built-in system user\n\nSends a `GET` request to `/users/{user_name}`\n\nArguments:\n- `user_name`: The built-in user's unique name.\n"] + ///Fetch a specific built-in system user + /// + ///Sends a `GET` request to `/users/{user_name}` + /// + ///Arguments: + /// - `user_name`: The built-in user's unique name. pub async fn users_get_user<'a>( &'a self, user_name: &'a types::Name, @@ -5462,7 +6337,7 @@ impl Client { let url = format!( "{}/users/{}", self.baseurl, - progenitor_client::encode_path(&user_name.to_string()), + encode_path(&user_name.to_string()), ); let request = self.client.get(url).build()?; let result = self.client.execute(request).await; diff --git a/progenitor-impl/tests/output/test_default_params.out b/progenitor-impl/tests/output/test_default_params.out index ec284f9..8cb3921 100644 --- a/progenitor-impl/tests/output/test_default_params.out +++ b/progenitor-impl/tests/output/test_default_params.out @@ -1,3 +1,5 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; @@ -20,7 +22,7 @@ pub mod types { pub yes: bool, } - #[doc = "Error information from a response."] + ///Error information from a response. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -32,8 +34,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -61,14 +63,16 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "Sends a `POST` request to ``"] +impl Client { + ///Sends a `POST` request to `` pub async fn default_params<'a>( &'a self, body: &'a types::BodyWithDefaults, ) -> Result, Error> { let url = format!("{}", self.baseurl,); - let request = self.client.post(url).json(body).build()?; + let request = self.client.post(url).json(&body).build()?; let result = self.client.execute(request).await; let response = result?; match response.status().as_u16() { diff --git a/progenitor-impl/tests/output/test_freeform_response.out b/progenitor-impl/tests/output/test_freeform_response.out index 4ef8082..a11367e 100644 --- a/progenitor-impl/tests/output/test_freeform_response.out +++ b/progenitor-impl/tests/output/test_freeform_response.out @@ -1,7 +1,9 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; - #[doc = "Error information from a response."] + ///Error information from a response. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -13,8 +15,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -42,8 +44,10 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "Sends a `GET` request to ``"] +impl Client { + ///Sends a `GET` request to `` pub async fn freeform_response<'a>( &'a self, ) -> Result, Error> { diff --git a/progenitor-impl/tests/output/test_renamed_parameters.out b/progenitor-impl/tests/output/test_renamed_parameters.out index eb0ad2f..5c73d9c 100644 --- a/progenitor-impl/tests/output/test_renamed_parameters.out +++ b/progenitor-impl/tests/output/test_renamed_parameters.out @@ -1,7 +1,9 @@ +#[allow(unused_imports)] +use progenitor_client::encode_path; pub use progenitor_client::{ByteStream, Error, ResponseValue}; pub mod types { use serde::{Deserialize, Serialize}; - #[doc = "Error information from a response."] + ///Error information from a response. #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Error { #[serde(default, skip_serializing_if = "Option::is_none")] @@ -13,8 +15,8 @@ pub mod types { #[derive(Clone)] pub struct Client { - baseurl: String, - client: reqwest::Client, + pub(crate) baseurl: String, + pub(crate) client: reqwest::Client, } impl Client { @@ -42,8 +44,10 @@ impl Client { pub fn client(&self) -> &reqwest::Client { &self.client } +} - #[doc = "Sends a `GET` request to `/{ref}/{type}/{trait}`"] +impl Client { + ///Sends a `GET` request to `/{ref}/{type}/{trait}` pub async fn renamed_parameters<'a>( &'a self, ref_: &'a str, @@ -56,9 +60,9 @@ impl Client { let url = format!( "{}/{}/{}/{}", self.baseurl, - progenitor_client::encode_path(&ref_.to_string()), - progenitor_client::encode_path(&type_.to_string()), - progenitor_client::encode_path(&trait_.to_string()), + encode_path(&ref_.to_string()), + encode_path(&type_.to_string()), + encode_path(&trait_.to_string()), ); let mut query = Vec::new(); query.push(("if", if_.to_string())); diff --git a/progenitor-impl/tests/test_output.rs b/progenitor-impl/tests/test_output.rs index c29e44d..cf4762a 100644 --- a/progenitor-impl/tests/test_output.rs +++ b/progenitor-impl/tests/test_output.rs @@ -2,36 +2,61 @@ use std::{fs::File, path::PathBuf}; -use progenitor_impl::Generator; +use progenitor_impl::{ + GenerationSettings, Generator, InterfaceStyle, TagStyle, +}; #[track_caller] -fn verify_file(openapi_file: &str) { +fn verify_apis(openapi_file: &str) { let mut in_path = PathBuf::from("../sample_openapi"); in_path.push(format!("{}.json", openapi_file)); let file = File::open(in_path).unwrap(); let spec = serde_json::from_reader(file).unwrap(); - let mut generator = Generator::new(); - let output = generator.generate_text(&spec).unwrap(); + + let mut generator = Generator::default(); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); expectorate::assert_contents( - format!("tests/output/{}.out", openapi_file), + format!("tests/output/{}-positional.out", openapi_file), &output, - ) + ); + + let mut generator = Generator::new( + GenerationSettings::default() + .with_interface(InterfaceStyle::Builder) + .with_tag(TagStyle::Merged), + ); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); + expectorate::assert_contents( + format!("tests/output/{}-builder.out", openapi_file), + &output, + ); + + let mut generator = Generator::new( + GenerationSettings::default() + .with_interface(InterfaceStyle::Builder) + .with_tag(TagStyle::Separate), + ); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); + expectorate::assert_contents( + format!("tests/output/{}-builder-tagged.out", openapi_file), + &output, + ); } #[test] fn test_keeper() { - verify_file("keeper"); + verify_apis("keeper"); } #[test] fn test_buildomat() { - verify_file("buildomat"); + verify_apis("buildomat"); } #[test] fn test_nexus() { - verify_file("nexus"); + verify_apis("nexus"); } // TODO this file is full of inconsistencies and incorrectly specified types. @@ -40,5 +65,5 @@ fn test_nexus() { #[ignore] #[test] fn test_github() { - verify_file("api.github.com"); + verify_apis("api.github.com"); } diff --git a/progenitor-impl/tests/test_specific.rs b/progenitor-impl/tests/test_specific.rs index e021900..e6e0a41 100644 --- a/progenitor-impl/tests/test_specific.rs +++ b/progenitor-impl/tests/test_specific.rs @@ -64,8 +64,8 @@ fn test_renamed_parameters() { let spec = serde_json::from_str::(out).unwrap(); - let mut generator = Generator::new(); - let output = generator.generate_text(&spec).unwrap(); + let mut generator = Generator::default(); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); expectorate::assert_contents( format!("tests/output/{}.out", "test_renamed_parameters"), &output, @@ -97,8 +97,8 @@ fn test_freeform_response() { let out = from_utf8(&out).unwrap(); let spec = serde_json::from_str::(out).unwrap(); - let mut generator = Generator::new(); - let output = generator.generate_text(&spec).unwrap(); + let mut generator = Generator::default(); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); expectorate::assert_contents( format!("tests/output/{}.out", "test_freeform_response"), &output, @@ -145,8 +145,8 @@ fn test_default_params() { let out = from_utf8(&out).unwrap(); let spec = serde_json::from_str::(out).unwrap(); - let mut generator = Generator::new(); - let output = generator.generate_text(&spec).unwrap(); + let mut generator = Generator::default(); + let output = generator.generate_text_normalize_comments(&spec).unwrap(); expectorate::assert_contents( format!("tests/output/{}.out", "test_default_params"), &output, diff --git a/progenitor-macro/Cargo.toml b/progenitor-macro/Cargo.toml index ccec6d7..12ed0ce 100644 --- a/progenitor-macro/Cargo.toml +++ b/progenitor-macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "progenitor-macro" version = "0.1.2-dev" -edition = "2018" +edition = "2021" license = "MPL-2.0" repository = "https://github.com/oxidecomputer/progenitor.git" description = "An OpenAPI client generator - macros" diff --git a/progenitor-macro/src/lib.rs b/progenitor-macro/src/lib.rs index 328441b..7ae3fa1 100644 --- a/progenitor-macro/src/lib.rs +++ b/progenitor-macro/src/lib.rs @@ -4,7 +4,9 @@ use std::path::Path; use openapiv3::OpenAPI; use proc_macro::TokenStream; -use progenitor_impl::Generator; +use progenitor_impl::{ + GenerationSettings, Generator, InterfaceStyle, TagStyle, +}; use quote::{quote, ToTokens}; use serde::Deserialize; use serde_tokenstream::ParseWrapper; @@ -22,7 +24,8 @@ use syn::LitStr; /// ```ignore /// generate_api!( /// spec = "path/to/spec.json", -/// [ inner_type = path::to:Type, ] +/// [ interface = ( Positional | Builder ), ] +/// [ tags = ( Merged | Separate ), ] /// [ pre_hook = closure::or::path::to::function, ] /// [ post_hook = closure::or::path::to::function, ] /// [ derives = [ path::to::DeriveMacro ], ] @@ -32,6 +35,14 @@ use syn::LitStr; /// The `spec` key is required; it is the OpenAPI document from which the /// client is derived. /// +/// The optional `interface` lets you specify either a `Positional` argument or +/// `Builder` argument style; `Positional` is the default. +/// +/// The optional `tags` may be `Merged` in which case all operations are +/// methods on the `Client` struct or `Separate` in which case each tag is +/// represented by an "extension trait" that `Client` implements. The default +/// is `Merged`. +/// /// The optional `inner_type` is for ancillary data, stored with the generated /// client that can be usd by the pre and post hooks. /// @@ -58,8 +69,12 @@ pub fn generate_api(item: TokenStream) -> TokenStream { } #[derive(Deserialize)] -struct Settings { +struct MacroSettings { spec: ParseWrapper, + #[serde(default)] + interface: InterfaceStyle, + #[serde(default)] + tags: TagStyle, inner_type: Option>, pre_hook: Option>, post_hook: Option>, @@ -67,6 +82,18 @@ struct Settings { derives: Vec>, } +#[derive(Deserialize)] +enum GenerationStyle { + Positional, + Builder, +} + +impl Default for GenerationStyle { + fn default() -> Self { + Self::Positional + } +} + #[derive(Debug)] struct ClosureOrPath(proc_macro2::TokenStream); @@ -90,25 +117,35 @@ impl syn::parse::Parse for ClosureOrPath { } fn do_generate_api(item: TokenStream) -> Result { - let (spec, inner_type, pre_hook, post_hook, derives) = - if let Ok(spec) = syn::parse::(item.clone()) { - (spec, None, None, None, Vec::new()) - } else { - let Settings { - spec, - inner_type, - pre_hook, - post_hook, - derives, - } = serde_tokenstream::from_tokenstream(&item.into())?; - ( - spec.into_inner(), - inner_type.map(|x| x.into_inner()), - pre_hook.map(|x| x.into_inner()), - post_hook.map(|x| x.into_inner()), - derives.into_iter().map(ParseWrapper::into_inner).collect(), - ) - }; + let (spec, settings) = if let Ok(spec) = syn::parse::(item.clone()) + { + (spec, GenerationSettings::default()) + } else { + let MacroSettings { + spec, + interface, + tags, + inner_type, + pre_hook, + post_hook, + derives, + } = serde_tokenstream::from_tokenstream(&item.into())?; + let mut settings = GenerationSettings::default(); + settings.with_interface(interface); + settings.with_tag(tags); + inner_type.map(|inner_type| { + settings.with_inner_type(inner_type.to_token_stream()) + }); + pre_hook + .map(|pre_hook| settings.with_pre_hook(pre_hook.into_inner().0)); + post_hook + .map(|post_hook| settings.with_post_hook(post_hook.into_inner().0)); + + derives.into_iter().for_each(|derive| { + settings.with_derive(derive.to_token_stream()); + }); + (spec.into_inner(), settings) + }; let dir = std::env::var("CARGO_MANIFEST_DIR").map_or_else( |_| std::env::current_dir().unwrap(), @@ -122,31 +159,22 @@ fn do_generate_api(item: TokenStream) -> Result { serde_json::from_reader(std::fs::File::open(&path).map_err(|e| { syn::Error::new( spec.span(), - format!("couldn't read file {}: {}", path_str, e.to_string()), + format!("couldn't read file {}: {}", path_str, e), ) })?) .map_err(|e| { syn::Error::new( spec.span(), - format!("failed to parse {}: {}", path_str, e.to_string()), + format!("failed to parse {}: {}", path_str, e), ) })?; - let mut builder = Generator::new(); - inner_type.map(|inner_type| { - builder.with_inner_type(inner_type.to_token_stream()) - }); - pre_hook.map(|pre_hook| builder.with_pre_hook(pre_hook.0)); - post_hook.map(|post_hook| builder.with_post_hook(post_hook.0)); - - derives.into_iter().for_each(|derive| { - builder.with_derive(derive.to_token_stream()); - }); + let mut builder = Generator::new(&settings); let code = builder.generate_tokens(&oapi).map_err(|e| { syn::Error::new( spec.span(), - format!("generation error for {}: {}", spec.value(), e.to_string()), + format!("generation error for {}: {}", spec.value(), e), ) })?; diff --git a/progenitor/Cargo.toml b/progenitor/Cargo.toml index 3643cb4..7002817 100644 --- a/progenitor/Cargo.toml +++ b/progenitor/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "progenitor" version = "0.1.2-dev" -edition = "2018" +edition = "2021" license = "MPL-2.0" repository = "https://github.com/oxidecomputer/progenitor.git" description = "An OpenAPI client generator" @@ -11,10 +11,10 @@ progenitor-client = { version = "0.1.2-dev", path = "../progenitor-client" } progenitor-impl = { version = "0.1.2-dev", path = "../progenitor-impl" } progenitor-macro = { version = "0.1.2-dev", path = "../progenitor-macro" } anyhow = "1.0" -getopts = "0.2" openapiv3 = "1.0.0" -serde = { version = "1.0", features = [ "derive" ] } +serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" +clap = { version = "3.2.8", features = ["derive"] } [dev-dependencies] chrono = { version = "0.4", features = ["serde"] } diff --git a/progenitor/src/lib.rs b/progenitor/src/lib.rs index 1c8d642..d7a7632 100644 --- a/progenitor/src/lib.rs +++ b/progenitor/src/lib.rs @@ -12,5 +12,8 @@ pub use progenitor_client; pub use progenitor_impl::Error; +pub use progenitor_impl::GenerationSettings; pub use progenitor_impl::Generator; +pub use progenitor_impl::InterfaceStyle; +pub use progenitor_impl::TagStyle; pub use progenitor_macro::generate_api; diff --git a/progenitor/src/main.rs b/progenitor/src/main.rs index 10bdbbe..317bf6f 100644 --- a/progenitor/src/main.rs +++ b/progenitor/src/main.rs @@ -8,10 +8,64 @@ use std::{ }; use anyhow::{bail, Result}; +use clap::{Parser, ValueEnum}; use openapiv3::OpenAPI; -use progenitor::Generator; +use progenitor::{GenerationSettings, Generator, InterfaceStyle, TagStyle}; use serde::Deserialize; +#[derive(Parser)] +struct Args { + /// OpenAPI definition document (JSON) + #[clap(short = 'i', long)] + input: String, + /// Output directory for Rust crate + #[clap(short = 'o', long)] + output: String, + /// Target Rust crate name + #[clap(short = 'n', long)] + name: String, + /// Target Rust crate version + #[clap(short = 'v', long)] + version: String, + + /// SDK interface style + #[clap(value_enum, long, default_value_t = InterfaceArg::Positional)] + interface: InterfaceArg, + /// SDK tag style + #[clap(value_enum, long, default_value_t = TagArg::Merged)] + tags: TagArg, +} + +#[derive(Copy, Clone, ValueEnum)] +enum InterfaceArg { + Positional, + Builder, +} + +impl From for InterfaceStyle { + fn from(arg: InterfaceArg) -> Self { + match arg { + InterfaceArg::Positional => InterfaceStyle::Positional, + InterfaceArg::Builder => InterfaceStyle::Builder, + } + } +} + +#[derive(Copy, Clone, ValueEnum)] +enum TagArg { + Merged, + Separate, +} + +impl From for TagStyle { + fn from(arg: TagArg) -> Self { + match arg { + TagArg::Merged => TagStyle::Merged, + TagArg::Separate => TagStyle::Separate, + } + } +} + fn save

(p: P, data: &str) -> Result<()> where P: AsRef, @@ -28,30 +82,15 @@ where } fn main() -> Result<()> { - let mut opts = getopts::Options::new(); - opts.parsing_style(getopts::ParsingStyle::StopAtFirstFree); - opts.reqopt("i", "", "OpenAPI definition document (JSON)", "INPUT"); - opts.reqopt("o", "", "Generated Rust crate directory", "OUTPUT"); - opts.reqopt("n", "", "Target Rust crate name", "CRATE"); - opts.reqopt("v", "", "Target Rust crate version", "VERSION"); + let args = Args::parse(); + let api = load_api(&args.input)?; - let args = match opts.parse(std::env::args().skip(1)) { - Ok(args) => { - if !args.free.is_empty() { - eprintln!("{}", opts.usage("progenitor")); - bail!("unexpected positional arguments"); - } - args - } - Err(e) => { - eprintln!("{}", opts.usage("progenitor")); - bail!(e); - } - }; - - let api = load_api(&args.opt_str("i").unwrap())?; - - let mut builder = Generator::new(); + //let mut builder = Generator::default(); + let mut builder = Generator::new( + GenerationSettings::default() + .with_interface(args.interface.into()) + .with_tag(args.tags.into()), + ); match builder.generate_text(&api) { Ok(api_code) => { @@ -67,13 +106,13 @@ fn main() -> Result<()> { println!("-----------------------------------------------------"); println!(); - let name = args.opt_str("n").unwrap(); - let version = args.opt_str("v").unwrap(); + let name = &args.name; + let version = &args.version; /* * Create the top-level crate directory: */ - let root = PathBuf::from(args.opt_str("o").unwrap()); + let root = PathBuf::from(&args.output); std::fs::create_dir_all(&root)?; /* diff --git a/progenitor/tests/build_buildomat.rs b/progenitor/tests/build_buildomat.rs index d9b2d5e..aea3747 100644 --- a/progenitor/tests/build_buildomat.rs +++ b/progenitor/tests/build_buildomat.rs @@ -1,3 +1,41 @@ -// Copyright 2021 Oxide Computer Company +// Copyright 2022 Oxide Computer Company -progenitor::generate_api!("../sample_openapi/buildomat.json"); +mod positional { + progenitor::generate_api!("../sample_openapi/buildomat.json"); + + fn _ignore() { + let _ = Client::new("").worker_task_upload_chunk("task", vec![0]); + } +} + +mod builder_untagged { + progenitor::generate_api!( + spec = "../sample_openapi/buildomat.json", + interface = Builder, + tags = Merged, + ); + + fn _ignore() { + let _ = Client::new("") + .worker_task_upload_chunk() + .task("task") + .body(vec![0]) + .send(); + } +} + +mod builder_tagged { + progenitor::generate_api!( + spec = "../sample_openapi/buildomat.json", + interface = Builder, + tags = Separate, + ); + + fn _ignore() { + let _ = Client::new("") + .worker_task_upload_chunk() + .task("task") + .body(vec![0]) + .send(); + } +} diff --git a/progenitor/tests/build_keeper.rs b/progenitor/tests/build_keeper.rs index 5bcfdb5..805ba74 100644 --- a/progenitor/tests/build_keeper.rs +++ b/progenitor/tests/build_keeper.rs @@ -1,3 +1,48 @@ -// Copyright 2021 Oxide Computer Company +// Copyright 2022 Oxide Computer Company -progenitor::generate_api!("../sample_openapi/keeper.json"); +mod positional { + progenitor::generate_api!("../sample_openapi/keeper.json"); + + fn _ignore() { + let _ = Client::new("").enrol(&types::EnrolBody { + host: "".to_string(), + key: "".to_string(), + }); + } +} + +mod builder_untagged { + progenitor::generate_api!( + spec = "../sample_openapi/keeper.json", + interface = Builder, + tags = Merged, + ); + + fn _ignore() { + let _ = Client::new("") + .enrol() + .body(types::EnrolBody { + host: "".to_string(), + key: "".to_string(), + }) + .send(); + } +} + +mod builder_tagged { + progenitor::generate_api!( + spec = "../sample_openapi/keeper.json", + interface = Builder, + tags = Separate, + ); + + fn _ignore() { + let _ = Client::new("") + .enrol() + .body(types::EnrolBody { + host: "".to_string(), + key: "".to_string(), + }) + .send(); + } +} diff --git a/progenitor/tests/build_nexus.rs b/progenitor/tests/build_nexus.rs index e892e59..1a41d24 100644 --- a/progenitor/tests/build_nexus.rs +++ b/progenitor/tests/build_nexus.rs @@ -1,23 +1,74 @@ // Copyright 2021 Oxide Computer Company -progenitor::generate_api!("../sample_openapi/nexus.json"); +mod positional { + use futures::StreamExt; -pub async fn iteration_example() { - let client = Client::new("xxx"); + mod nexus_client { + progenitor::generate_api!("../sample_openapi/nexus.json"); + } - let bod = types::LoginParams { - username: "ahl".to_string(), - }; + use nexus_client::{types, Client}; - let mut stream = client.spoof_login(&bod).await.unwrap(); - - loop { - use futures::TryStreamExt; - - match stream.try_next().await { - Ok(Some(bytes)) => println!("bytes: {:?}", bytes), - Ok(None) => break, - Err(e) => panic!("{}", e), - } + fn _ignore() { + let _ = async { + let client = Client::new(""); + let org = types::Name("org".to_string()); + let project = types::Name("project".to_string()); + let instance = types::Name("instance".to_string()); + let stream = client.instance_disks_get_stream( + &org, &project, &instance, None, None, + ); + let _ = stream.collect::>(); + }; + } +} + +mod builder_untagged { + use futures::StreamExt; + + mod nexus_client { + progenitor::generate_api!( + spec = "../sample_openapi/nexus.json", + interface = Builder, + tags = Merged, + ); + } + + use nexus_client::{types, Client}; + + pub fn _ignore() { + let client = Client::new(""); + let stream = client + .instance_disks_get() + .organization_name(types::Name("org".to_string())) + .project_name(types::Name("project".to_string())) + .instance_name(types::Name("instance".to_string())) + .stream(); + let _ = stream.collect::>(); + } +} + +mod builder_tagged { + use futures::StreamExt; + + mod nexus_client { + progenitor::generate_api!( + spec = "../sample_openapi/nexus.json", + interface = Builder, + tags = Separate, + ); + } + + use nexus_client::{types, Client, ClientInstancesExt}; + + fn _ignore() { + let client = Client::new(""); + let stream = client + .instance_disks_get() + .organization_name(types::Name("org".to_string())) + .project_name(types::Name("project".to_string())) + .instance_name(types::Name("instance".to_string())) + .stream(); + let _ = stream.collect::>(); } }