From d0b9842ce32a885d22ee98817efc52724b669196 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Thu, 23 Mar 2023 18:11:44 -0700 Subject: [PATCH] use body builder types in operation builders (#385) --- Cargo.lock | 6 +- progenitor-impl/src/method.rs | 162 ++- .../tests/output/buildomat-builder-tagged.out | 127 +- .../tests/output/buildomat-builder.out | 127 +- .../tests/output/keeper-builder-tagged.out | 84 +- .../tests/output/keeper-builder.out | 84 +- .../tests/output/nexus-builder-tagged.out | 1065 ++++++++++++++--- .../tests/output/nexus-builder.out | 1065 ++++++++++++++--- .../tests/output/nexus-positional.out | 2 +- .../output/propolis-server-builder-tagged.out | 78 +- .../tests/output/propolis-server-builder.out | 78 +- .../output/test_default_params_builder.out | 25 +- .../output/test_default_params_positional.out | 2 +- 13 files changed, 2440 insertions(+), 465 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 542e2e0..161c630 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2122,7 +2122,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "typify" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#44f52879905a135d37ed06aaf87dbd9df5d72b2f" +source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" dependencies = [ "typify-impl", "typify-macro", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#44f52879905a135d37ed06aaf87dbd9df5d72b2f" +source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" dependencies = [ "heck", "log", @@ -2148,7 +2148,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#44f52879905a135d37ed06aaf87dbd9df5d72b2f" +source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" dependencies = [ "proc-macro2", "quote", diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index c2a5d4b..1475e92 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -1357,8 +1357,19 @@ impl Generator { .map(|param| match ¶m.typ { OperationParameterType::Type(type_id) => { let ty = self.type_space.get_type(type_id)?; - let t = ty.ident(); - Ok(quote! { Result<#t, String> }) + + // For body parameters only, if there's a builder we'll + // nest that within this builder. + if let ( + OperationParameterKind::Body(_), + Some(builder_name), + ) = (¶m.kind, ty.builder()) + { + Ok(quote! { Result<#builder_name, String> }) + } else { + let t = ty.ident(); + Ok(quote! { Result<#t, String> }) + } } OperationParameterType::RawBody => { @@ -1372,24 +1383,52 @@ impl Generator { let param_values = method .params .iter() - .map(|param| { - let opt = match ¶m.typ { - OperationParameterType::Type(type_id) => { - let ty = self.type_space.get_type(type_id)?; - let details = ty.details(); - matches!(&details, typify::TypeDetails::Option(_)) + .map(|param| match ¶m.typ { + OperationParameterType::Type(type_id) => { + let ty = self.type_space.get_type(type_id)?; + let details = ty.details(); + let optional = + matches!(&details, typify::TypeDetails::Option(_)); + if optional { + Ok(quote! { Ok(None) }) + } else if let ( + OperationParameterKind::Body(_), + Some(builder_name), + ) = (¶m.kind, ty.builder()) + { + Ok(quote! { Ok(#builder_name :: default()) }) + } else { + let err_msg = + format!("{} was not initialized", param.name); + Ok(quote! { Err(#err_msg.to_string()) }) } - OperationParameterType::RawBody => false, - }; - if opt { - Ok(quote! { Ok(None) }) - } else { + } + OperationParameterType::RawBody => { let err_msg = format!("{} was not initialized", param.name); Ok(quote! { Err(#err_msg.to_string()) }) } }) .collect::>>()?; + let param_xxx = method + .params + .iter() + .map(|param| match ¶m.typ { + OperationParameterType::Type(type_id) => { + let ty = self.type_space.get_type(type_id)?; + if let Some(_) = ty.builder() { + let type_name = ty.ident(); + Ok(quote! { + .and_then(#type_name :: try_from) + }) + } else { + Ok(quote! {}) + } + } + OperationParameterType::RawBody => Ok(quote! {}), + }) + .collect::>>()?; + // For each parameter, we need an impl for the builder to let consumers // provide a value. let param_impls = method @@ -1401,8 +1440,13 @@ impl Generator { OperationParameterType::Type(type_id) => { let ty = self.type_space.get_type(type_id)?; let details = ty.details(); - match &details { - typify::TypeDetails::Option(opt_id) => { + match (&details, ty.builder()) { + // TODO right now optional body paramters are not + // addressed + (typify::TypeDetails::Option(_), Some(_)) => { + unreachable!() + } + (typify::TypeDetails::Option(opt_id), None) => { // TODO currently we explicitly turn optional // parameters into Option types; we could // probably defer this to the code generation @@ -1429,7 +1473,7 @@ impl Generator { } }) } - _ => { + (_, None) => { let typ = ty.ident(); let err_msg = format!( "conversion to `{}` for {} failed", @@ -1449,6 +1493,35 @@ impl Generator { } }) } + (_, Some(builder_name)) => { + assert_eq!(param.name, "body"); + let typ = ty.ident(); + let err_msg = format!( + "conversion to `{}` for {} failed", + ty.name(), + param.name, + ); + Ok(quote! { + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto<#typ>, + { + self.body = value.try_into() + .map(From::from) + .map_err(|_| #err_msg.to_string()); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(#builder_name) + -> #builder_name, + { + self.body = self.body.map(f); + self + } + }) + } } } @@ -1483,6 +1556,35 @@ impl Generator { 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, + #( #param_names, )* + } = self; + + // Extract parameters into variables, returning an error if + // a value has not been provided or there was a conversion + // error. + // + // TODO we could do something a bit nicer by collecting all + // errors rather than just reporting the first one. + #( + let #param_names = + #param_names + #param_xxx + .map_err(Error::InvalidRequest)?; + )* + + // Do the work. + #body + } + }; let stream_impl = method.dropshot_paginated.as_ref().map(|page_data| { // We're now using futures. @@ -1668,33 +1770,7 @@ impl Generator { } #( #param_impls )* - - #[doc = #send_doc] - pub async fn send(self) -> Result< - ResponseValue<#success>, - Error<#error>, - > { - // Destructure the builder for convenience. - let Self { - client, - #( #param_names, )* - } = self; - - // Extract parameters into variables, returning an error if - // a value has not been provided or there was a conversion - // error. - // - // TODO we could do something a bit nicer by collecting all - // errors rather than just reporting the first one. - #( - let #param_names = - #param_names.map_err(Error::InvalidRequest)?; - )* - - // Do the work. - #body - } - + #send_impl #stream_impl } }) diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out index 30f2d26..7f5d499 100644 --- a/progenitor-impl/tests/output/buildomat-builder-tagged.out +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -363,7 +363,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct Task { id: Result, name: Result, @@ -462,6 +463,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskEvent { payload: Result, seq: Result, @@ -546,6 +548,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskOutput { id: Result, path: Result, @@ -616,6 +619,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskSubmit { name: Result, output_rules: Result, String>, @@ -686,6 +690,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskSubmitResult { id: Result, } @@ -724,6 +729,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UploadedChunk { id: Result, } @@ -762,6 +768,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreate { name: Result, } @@ -802,6 +809,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreateResult { id: Result, name: Result, @@ -872,6 +880,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WhoamiResult { id: Result, name: Result, @@ -928,6 +937,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Worker { deleted: Result, id: Result, @@ -1040,6 +1050,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerAddOutput { chunks: Result, String>, path: Result, @@ -1110,6 +1121,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerAppendTask { payload: Result, stream: Result, @@ -1180,6 +1192,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerBootstrap { bootstrap: Result, token: Result, @@ -1236,6 +1249,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerBootstrapResult { id: Result, } @@ -1274,6 +1288,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerCompleteTask { failed: Result, } @@ -1316,6 +1331,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerPingResult { poweroff: Result, task: Result, String>, @@ -1372,6 +1388,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerPingTask { id: Result, output_rules: Result, String>, @@ -1442,6 +1459,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerTask { id: Result, name: Result, @@ -1512,6 +1530,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkersResult { workers: Result, String>, } @@ -1959,14 +1978,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct TaskSubmit<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> TaskSubmit<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::TaskSubmit::default()), } } @@ -1976,14 +1995,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/tasks` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::TaskSubmit::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/tasks", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2179,14 +2209,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct UserCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> UserCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UserCreate::default()), } } @@ -2196,14 +2226,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/users` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UserCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/users", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2248,14 +2289,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct WorkerBootstrap<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> WorkerBootstrap<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerBootstrap::default()), } } @@ -2265,14 +2306,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/bootstrap` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerBootstrap::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/worker/bootstrap", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2318,7 +2370,7 @@ pub mod builder { pub struct WorkerTaskAppend<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskAppend<'a> { @@ -2326,7 +2378,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerAppendTask::default()), } } @@ -2346,15 +2398,28 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerAppendTask, + ) -> types::builder::WorkerAppendTask, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/append` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerAppendTask::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/append", client.baseurl, @@ -2444,7 +2509,7 @@ pub mod builder { pub struct WorkerTaskComplete<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskComplete<'a> { @@ -2452,7 +2517,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteTask::default()), } } @@ -2472,15 +2537,28 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerCompleteTask::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/complete", client.baseurl, @@ -2503,7 +2581,7 @@ pub mod builder { pub struct WorkerTaskAddOutput<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskAddOutput<'a> { @@ -2511,7 +2589,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerAddOutput::default()), } } @@ -2531,15 +2609,26 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerAddOutput` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAddOutput) -> types::builder::WorkerAddOutput, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/output` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerAddOutput::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/output", client.baseurl, diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out index ba7d595..654b83e 100644 --- a/progenitor-impl/tests/output/buildomat-builder.out +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -363,7 +363,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct Task { id: Result, name: Result, @@ -462,6 +463,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskEvent { payload: Result, seq: Result, @@ -546,6 +548,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskOutput { id: Result, path: Result, @@ -616,6 +619,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskSubmit { name: Result, output_rules: Result, String>, @@ -686,6 +690,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TaskSubmitResult { id: Result, } @@ -724,6 +729,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UploadedChunk { id: Result, } @@ -762,6 +768,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreate { name: Result, } @@ -802,6 +809,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreateResult { id: Result, name: Result, @@ -872,6 +880,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WhoamiResult { id: Result, name: Result, @@ -928,6 +937,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Worker { deleted: Result, id: Result, @@ -1040,6 +1050,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerAddOutput { chunks: Result, String>, path: Result, @@ -1110,6 +1121,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerAppendTask { payload: Result, stream: Result, @@ -1180,6 +1192,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerBootstrap { bootstrap: Result, token: Result, @@ -1236,6 +1249,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerBootstrapResult { id: Result, } @@ -1274,6 +1288,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerCompleteTask { failed: Result, } @@ -1316,6 +1331,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerPingResult { poweroff: Result, task: Result, String>, @@ -1372,6 +1388,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerPingTask { id: Result, output_rules: Result, String>, @@ -1442,6 +1459,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkerTask { id: Result, name: Result, @@ -1512,6 +1530,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct WorkersResult { workers: Result, String>, } @@ -1959,14 +1978,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct TaskSubmit<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> TaskSubmit<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::TaskSubmit::default()), } } @@ -1976,14 +1995,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `TaskSubmit` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TaskSubmit) -> types::builder::TaskSubmit, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/tasks` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::TaskSubmit::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/tasks", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2179,14 +2209,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct UserCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> UserCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UserCreate::default()), } } @@ -2196,14 +2226,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/users` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UserCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/users", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2248,14 +2289,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct WorkerBootstrap<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> WorkerBootstrap<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerBootstrap::default()), } } @@ -2265,14 +2306,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerBootstrap` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerBootstrap) -> types::builder::WorkerBootstrap, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/bootstrap` pub async fn send(self) -> Result, Error<()>> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerBootstrap::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/worker/bootstrap", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2318,7 +2370,7 @@ pub mod builder { pub struct WorkerTaskAppend<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskAppend<'a> { @@ -2326,7 +2378,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerAppendTask::default()), } } @@ -2346,15 +2398,28 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerAppendTask` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerAppendTask, + ) -> types::builder::WorkerAppendTask, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/append` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerAppendTask::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/append", client.baseurl, @@ -2444,7 +2509,7 @@ pub mod builder { pub struct WorkerTaskComplete<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskComplete<'a> { @@ -2452,7 +2517,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerCompleteTask::default()), } } @@ -2472,15 +2537,28 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerCompleteTask` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::WorkerCompleteTask, + ) -> types::builder::WorkerCompleteTask, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/complete` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerCompleteTask::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/complete", client.baseurl, @@ -2503,7 +2581,7 @@ pub mod builder { pub struct WorkerTaskAddOutput<'a> { client: &'a super::Client, task: Result, - body: Result, + body: Result, } impl<'a> WorkerTaskAddOutput<'a> { @@ -2511,7 +2589,7 @@ pub mod builder { Self { client, task: Err("task was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::WorkerAddOutput::default()), } } @@ -2531,15 +2609,26 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `WorkerAddOutput` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::WorkerAddOutput) -> types::builder::WorkerAddOutput, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/worker/task/{task}/output` pub async fn send(self) -> Result, Error<()>> { let Self { client, task, body } = self; let task = task.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::WorkerAddOutput::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/worker/task/{}/output", client.baseurl, diff --git a/progenitor-impl/tests/output/keeper-builder-tagged.out b/progenitor-impl/tests/output/keeper-builder-tagged.out index a6e59e4..620b290 100644 --- a/progenitor-impl/tests/output/keeper-builder-tagged.out +++ b/progenitor-impl/tests/output/keeper-builder-tagged.out @@ -196,7 +196,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct EnrolBody { host: Result, key: Result, @@ -253,6 +254,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalJobsResult { summary: Result, String>, } @@ -295,6 +297,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OutputRecord { msg: Result, stream: Result, @@ -365,6 +368,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PingResult { host: Result, ok: Result, @@ -421,6 +425,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportFinishBody { duration_millis: Result, end_time: Result, String>, @@ -505,6 +510,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportId { host: Result, job: Result, @@ -603,6 +609,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportOutputBody { id: Result, record: Result, @@ -659,6 +666,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportResult { existed_already: Result, } @@ -701,6 +709,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportStartBody { id: Result, script: Result, @@ -771,6 +780,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportSummary { age_seconds: Result, duration_seconds: Result, @@ -1044,7 +1054,7 @@ pub mod builder { pub struct Enrol<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> Enrol<'a> { @@ -1052,7 +1062,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::EnrolBody::default()), } } @@ -1072,10 +1082,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `EnrolBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::EnrolBody) -> types::builder::EnrolBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/enrol` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1084,7 +1103,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::EnrolBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/enrol", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1204,7 +1225,7 @@ pub mod builder { pub struct ReportFinish<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportFinish<'a> { @@ -1212,7 +1233,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportFinishBody::default()), } } @@ -1232,10 +1253,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportFinishBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportFinishBody, + ) -> types::builder::ReportFinishBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/finish` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1244,7 +1276,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportFinishBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/finish", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1270,7 +1304,7 @@ pub mod builder { pub struct ReportOutput<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportOutput<'a> { @@ -1278,7 +1312,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportOutputBody::default()), } } @@ -1298,10 +1332,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportOutputBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportOutputBody, + ) -> types::builder::ReportOutputBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/output` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1310,7 +1355,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportOutputBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/output", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1336,7 +1383,7 @@ pub mod builder { pub struct ReportStart<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportStart<'a> { @@ -1344,7 +1391,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportStartBody::default()), } } @@ -1364,10 +1411,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportStartBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ReportStartBody) -> types::builder::ReportStartBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/start` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1376,7 +1432,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportStartBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/start", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); diff --git a/progenitor-impl/tests/output/keeper-builder.out b/progenitor-impl/tests/output/keeper-builder.out index 2dbca98..f086d41 100644 --- a/progenitor-impl/tests/output/keeper-builder.out +++ b/progenitor-impl/tests/output/keeper-builder.out @@ -196,7 +196,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct EnrolBody { host: Result, key: Result, @@ -253,6 +254,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalJobsResult { summary: Result, String>, } @@ -295,6 +297,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OutputRecord { msg: Result, stream: Result, @@ -365,6 +368,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PingResult { host: Result, ok: Result, @@ -421,6 +425,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportFinishBody { duration_millis: Result, end_time: Result, String>, @@ -505,6 +510,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportId { host: Result, job: Result, @@ -603,6 +609,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportOutputBody { id: Result, record: Result, @@ -659,6 +666,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportResult { existed_already: Result, } @@ -701,6 +709,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportStartBody { id: Result, script: Result, @@ -771,6 +780,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ReportSummary { age_seconds: Result, duration_seconds: Result, @@ -1044,7 +1054,7 @@ pub mod builder { pub struct Enrol<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> Enrol<'a> { @@ -1052,7 +1062,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::EnrolBody::default()), } } @@ -1072,10 +1082,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `EnrolBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::EnrolBody) -> types::builder::EnrolBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/enrol` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1084,7 +1103,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::EnrolBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/enrol", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1204,7 +1225,7 @@ pub mod builder { pub struct ReportFinish<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportFinish<'a> { @@ -1212,7 +1233,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportFinishBody::default()), } } @@ -1232,10 +1253,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportFinishBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportFinishBody, + ) -> types::builder::ReportFinishBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/finish` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1244,7 +1276,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportFinishBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/finish", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1270,7 +1304,7 @@ pub mod builder { pub struct ReportOutput<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportOutput<'a> { @@ -1278,7 +1312,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportOutputBody::default()), } } @@ -1298,10 +1332,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportOutputBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ReportOutputBody, + ) -> types::builder::ReportOutputBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/output` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1310,7 +1355,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportOutputBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/output", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); @@ -1336,7 +1383,7 @@ pub mod builder { pub struct ReportStart<'a> { client: &'a super::Client, authorization: Result, - body: Result, + body: Result, } impl<'a> ReportStart<'a> { @@ -1344,7 +1391,7 @@ pub mod builder { Self { client, authorization: Err("authorization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ReportStartBody::default()), } } @@ -1364,10 +1411,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ReportStartBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ReportStartBody) -> types::builder::ReportStartBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/report/start` pub async fn send(self) -> Result, Error<()>> { let Self { @@ -1376,7 +1432,9 @@ pub mod builder { body, } = self; let authorization = authorization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ReportStartBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/report/start", client.baseurl,); let mut header_map = HeaderMap::with_capacity(1usize); header_map.append("Authorization", HeaderValue::try_from(authorization)?); diff --git a/progenitor-impl/tests/output/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out index c1b0c32..d12a641 100644 --- a/progenitor-impl/tests/output/nexus-builder-tagged.out +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -6632,7 +6632,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct Baseboard { part: Result, revision: Result, @@ -6703,6 +6704,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Bindouble { count: Result, range: Result, @@ -6759,6 +6761,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Binint64 { count: Result, range: Result, @@ -6815,6 +6818,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Certificate { description: Result, id: Result, @@ -6927,6 +6931,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct CertificateCreate { cert: Result, String>, description: Result, @@ -7025,6 +7030,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct CertificateResultsPage { items: Result, String>, next_page: Result, String>, @@ -7081,6 +7087,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ComponentUpdate { component_type: Result, id: Result, @@ -7179,6 +7186,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ComponentUpdateResultsPage { items: Result, String>, next_page: Result, String>, @@ -7235,6 +7243,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Cumulativedouble { start_time: Result, String>, value: Result, @@ -7291,6 +7300,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Cumulativeint64 { start_time: Result, String>, value: Result, @@ -7347,6 +7357,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DerEncodedKeyPair { private_key: Result, public_cert: Result, @@ -7403,6 +7414,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAccessTokenRequest { client_id: Result, device_code: Result, @@ -7473,6 +7485,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAuthRequest { client_id: Result, } @@ -7515,6 +7528,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAuthVerify { user_code: Result, } @@ -7557,6 +7571,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Disk { block_size: Result, description: Result, @@ -7753,6 +7768,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskCreate { description: Result, disk_source: Result, @@ -7837,6 +7853,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskIdentifier { name: Result, } @@ -7877,6 +7894,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskPath { disk: Result, } @@ -7917,6 +7935,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -7973,6 +7992,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Distribution { name: Result, version: Result, @@ -8029,6 +8049,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Error { error_code: Result, String>, message: Result, @@ -8099,6 +8120,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ExternalIp { ip: Result, kind: Result, @@ -8155,6 +8177,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ExternalIpResultsPage { items: Result, String>, next_page: Result, String>, @@ -8211,6 +8234,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FieldSchema { name: Result, source: Result, @@ -8281,6 +8305,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FleetRolePolicy { role_assignments: Result, String>, } @@ -8326,6 +8351,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FleetRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -8396,6 +8422,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImage { block_size: Result, description: Result, @@ -8578,6 +8605,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImageCreate { block_size: Result, description: Result, @@ -8676,6 +8704,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImageResultsPage { items: Result, String>, next_page: Result, String>, @@ -8732,6 +8761,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Group { display_name: Result, id: Result, @@ -8802,6 +8832,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GroupResultsPage { items: Result, String>, next_page: Result, String>, @@ -8858,6 +8889,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Histogramdouble { bins: Result, String>, n_samples: Result, @@ -8928,6 +8960,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Histogramint64 { bins: Result, String>, n_samples: Result, @@ -8998,6 +9031,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IdentityProvider { description: Result, id: Result, @@ -9110,6 +9144,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IdentityProviderResultsPage { items: Result, String>, next_page: Result, String>, @@ -9166,6 +9201,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Image { block_size: Result, description: Result, @@ -9348,6 +9384,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ImageCreate { block_size: Result, description: Result, @@ -9432,6 +9469,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ImageResultsPage { items: Result, String>, next_page: Result, String>, @@ -9488,6 +9526,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Instance { description: Result, hostname: Result, @@ -9675,6 +9714,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceCreate { description: Result, disks: Result, String>, @@ -9846,6 +9886,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrate { dst_sled_id: Result, } @@ -9888,6 +9929,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceResultsPage { items: Result, String>, next_page: Result, String>, @@ -9944,6 +9986,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceSerialConsoleData { data: Result, String>, last_byte_offset: Result, @@ -10003,6 +10046,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPool { description: Result, id: Result, @@ -10101,6 +10145,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolCreate { description: Result, name: Result, @@ -10157,6 +10202,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolRange { id: Result, range: Result, @@ -10227,6 +10273,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolRangeResultsPage { items: Result, String>, next_page: Result, String>, @@ -10283,6 +10330,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolResultsPage { items: Result, String>, next_page: Result, String>, @@ -10339,6 +10387,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolUpdate { description: Result, String>, name: Result, String>, @@ -10395,6 +10444,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Ipv4Range { first: Result, last: Result, @@ -10451,6 +10501,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Ipv6Range { first: Result, last: Result, @@ -10507,6 +10558,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Measurement { datum: Result, timestamp: Result, String>, @@ -10563,6 +10615,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct MeasurementResultsPage { items: Result, String>, next_page: Result, String>, @@ -10619,6 +10672,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterface { description: Result, id: Result, @@ -10801,6 +10855,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceCreate { description: Result, ip: Result, String>, @@ -10899,6 +10954,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceResultsPage { items: Result, String>, next_page: Result, String>, @@ -10955,6 +11011,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceUpdate { description: Result, String>, name: Result, String>, @@ -11025,6 +11082,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Organization { description: Result, id: Result, @@ -11123,6 +11181,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationCreate { description: Result, name: Result, @@ -11179,6 +11238,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationResultsPage { items: Result, String>, next_page: Result, String>, @@ -11235,6 +11295,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationRolePolicy { role_assignments: Result, String>, } @@ -11280,6 +11341,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -11352,6 +11414,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationUpdate { description: Result, String>, name: Result, String>, @@ -11408,6 +11471,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PhysicalDisk { disk_type: Result, id: Result, @@ -11548,6 +11612,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PhysicalDiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -11604,6 +11669,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Project { description: Result, id: Result, @@ -11716,6 +11782,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectCreate { description: Result, name: Result, @@ -11772,6 +11839,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectResultsPage { items: Result, String>, next_page: Result, String>, @@ -11828,6 +11896,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectRolePolicy { role_assignments: Result, String>, } @@ -11873,6 +11942,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -11943,6 +12013,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectUpdate { description: Result, String>, name: Result, String>, @@ -11999,6 +12070,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Rack { id: Result, time_created: Result, String>, @@ -12069,6 +12141,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RackResultsPage { items: Result, String>, next_page: Result, String>, @@ -12125,6 +12198,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Role { description: Result, name: Result, @@ -12181,6 +12255,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RoleResultsPage { items: Result, String>, next_page: Result, String>, @@ -12237,6 +12312,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRoute { description: Result, destination: Result, @@ -12391,6 +12467,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteCreateParams { description: Result, destination: Result, @@ -12475,6 +12552,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteResultsPage { items: Result, String>, next_page: Result, String>, @@ -12531,6 +12609,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteUpdateParams { description: Result, String>, destination: Result, @@ -12615,6 +12694,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Saga { id: Result, state: Result, @@ -12671,6 +12751,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SagaResultsPage { items: Result, String>, next_page: Result, String>, @@ -12727,6 +12808,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SamlIdentityProvider { acs_url: Result, description: Result, @@ -12914,6 +12996,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SamlIdentityProviderCreate { acs_url: Result, description: Result, @@ -13095,6 +13178,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Silo { description: Result, discoverable: Result, @@ -13221,6 +13305,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloCreate { admin_group_name: Result, String>, description: Result, @@ -13322,6 +13407,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloResultsPage { items: Result, String>, next_page: Result, String>, @@ -13378,6 +13464,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloRolePolicy { role_assignments: Result, String>, } @@ -13423,6 +13510,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -13493,6 +13581,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Sled { baseboard: Result, id: Result, @@ -13591,6 +13680,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SledResultsPage { items: Result, String>, next_page: Result, String>, @@ -13647,6 +13737,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Snapshot { description: Result, disk_id: Result, @@ -13801,6 +13892,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SnapshotCreate { description: Result, disk: Result, @@ -13871,6 +13963,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SnapshotResultsPage { items: Result, String>, next_page: Result, String>, @@ -13927,6 +14020,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SpoofLoginBody { username: Result, } @@ -13969,6 +14063,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKey { description: Result, id: Result, @@ -14095,6 +14190,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKeyCreate { description: Result, name: Result, @@ -14165,6 +14261,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKeyResultsPage { items: Result, String>, next_page: Result, String>, @@ -14221,6 +14318,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdate { id: Result, time_created: Result, String>, @@ -14305,6 +14403,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdateResultsPage { items: Result, String>, next_page: Result, String>, @@ -14361,6 +14460,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdateStart { version: Result, } @@ -14403,6 +14503,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemVersion { status: Result, version_range: Result, @@ -14459,6 +14560,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TimeseriesSchema { created: Result, String>, datum_type: Result, @@ -14543,6 +14645,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TimeseriesSchemaResultsPage { items: Result, String>, next_page: Result, String>, @@ -14599,6 +14702,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateDeployment { id: Result, status: Result, @@ -14697,6 +14801,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateDeploymentResultsPage { items: Result, String>, next_page: Result, String>, @@ -14753,6 +14858,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateableComponent { component_type: Result, device_id: Result, @@ -14893,6 +14999,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateableComponentResultsPage { items: Result, String>, next_page: Result, String>, @@ -14951,6 +15058,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct User { display_name: Result, id: Result, @@ -15021,6 +15129,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserBuiltin { description: Result, id: Result, @@ -15119,6 +15228,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserBuiltinResultsPage { items: Result, String>, next_page: Result, String>, @@ -15175,6 +15285,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreate { external_id: Result, password: Result, @@ -15231,6 +15342,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserResultsPage { items: Result, String>, next_page: Result, String>, @@ -15287,6 +15399,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UsernamePasswordCredentials { password: Result, username: Result, @@ -15343,6 +15456,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VersionRange { high: Result, low: Result, @@ -15399,6 +15513,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Vpc { description: Result, dns_name: Result, @@ -15556,6 +15671,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcCreate { description: Result, dns_name: Result, @@ -15640,6 +15756,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRule { action: Result, description: Result, @@ -15836,6 +15953,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleFilter { hosts: Result>, String>, ports: Result>, String>, @@ -15906,6 +16024,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleUpdate { action: Result, description: Result, @@ -16046,6 +16165,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleUpdateParams { rules: Result, String>, } @@ -16088,6 +16208,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRules { rules: Result, String>, } @@ -16130,6 +16251,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcResultsPage { items: Result, String>, next_page: Result, String>, @@ -16186,6 +16308,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouter { description: Result, id: Result, @@ -16312,6 +16435,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterCreate { description: Result, name: Result, @@ -16368,6 +16492,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterResultsPage { items: Result, String>, next_page: Result, String>, @@ -16424,6 +16549,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterUpdate { description: Result, String>, name: Result, String>, @@ -16480,6 +16606,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnet { description: Result, id: Result, @@ -16620,6 +16747,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetCreate { description: Result, ipv4_block: Result, @@ -16704,6 +16832,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetResultsPage { items: Result, String>, next_page: Result, String>, @@ -16760,6 +16889,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetUpdate { description: Result, String>, name: Result, String>, @@ -16816,6 +16946,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcUpdate { description: Result, String>, dns_name: Result, String>, @@ -16887,7 +17018,7 @@ pub mod types { } } - mod defaults { + pub mod defaults { pub(super) fn default_bool() -> bool { V } @@ -21437,14 +21568,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAuthRequest<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAuthRequest<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAuthRequest::default()), } } @@ -21454,14 +21585,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DeviceAuthRequest` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthRequest, + ) -> types::builder::DeviceAuthRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/auth` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAuthRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/auth", client.baseurl,); let request = client.client.post(url).form_urlencoded(&body)?.build()?; let result = client.client.execute(request).await; @@ -21479,14 +21623,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAuthConfirm<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAuthConfirm<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAuthVerify::default()), } } @@ -21496,14 +21640,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DeviceAuthVerify` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthVerify, + ) -> types::builder::DeviceAuthVerify, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/confirm` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAuthVerify::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/confirm", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -21527,14 +21684,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAccessToken<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAccessToken<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAccessTokenRequest::default()), } } @@ -21542,16 +21699,28 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `DeviceAccessTokenRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAccessTokenRequest, + ) -> types::builder::DeviceAccessTokenRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/token` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAccessTokenRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/token", client.baseurl,); let request = client.client.post(url).form_urlencoded(&body)?.build()?; let result = client.client.execute(request).await; @@ -21709,14 +21878,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct LoginSpoof<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> LoginSpoof<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SpoofLoginBody::default()), } } @@ -21726,14 +21895,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SpoofLoginBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SpoofLoginBody) -> types::builder::SpoofLoginBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/login` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SpoofLoginBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/login", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -21758,7 +21938,7 @@ pub mod builder { pub struct LoginLocal<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> LoginLocal<'a> { @@ -21766,7 +21946,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UsernamePasswordCredentials::default()), } } @@ -21784,12 +21964,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `UsernamePasswordCredentials` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::UsernamePasswordCredentials, + ) -> types::builder::UsernamePasswordCredentials, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/login/{silo_name}/local` pub async fn send(self) -> Result, Error> { let Self { @@ -21798,7 +21988,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UsernamePasswordCredentials::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/login/{}/local", client.baseurl, @@ -22161,14 +22353,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct OrganizationCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> OrganizationCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationCreate::default()), } } @@ -22178,14 +22370,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/organizations` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/organizations", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -22265,7 +22470,7 @@ pub mod builder { pub struct OrganizationUpdate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> OrganizationUpdate<'a> { @@ -22273,7 +22478,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationUpdate::default()), } } @@ -22293,10 +22498,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/organizations/{organization_name}` pub async fn send(self) -> Result, Error> { let Self { @@ -22305,7 +22521,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}", client.baseurl, @@ -22446,7 +22664,7 @@ pub mod builder { pub struct OrganizationPolicyUpdate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> OrganizationPolicyUpdate<'a> { @@ -22454,7 +22672,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationRolePolicy::default()), } } @@ -22474,10 +22692,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` pub async fn send( self, @@ -22488,7 +22717,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/policy", client.baseurl, @@ -22677,7 +22908,7 @@ pub mod builder { pub struct ProjectCreate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> ProjectCreate<'a> { @@ -22685,7 +22916,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectCreate::default()), } } @@ -22705,10 +22936,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects` pub async fn send(self) -> Result, Error> { @@ -22718,7 +22958,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects", client.baseurl, @@ -22819,7 +23061,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ProjectUpdate<'a> { @@ -22828,7 +23070,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectUpdate::default()), } } @@ -22858,10 +23100,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}` pub async fn send(self) -> Result, Error> { @@ -22873,7 +23124,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}", client.baseurl, @@ -23150,7 +23403,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> DiskCreate<'a> { @@ -23159,7 +23412,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskCreate::default()), } } @@ -23189,10 +23442,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` pub async fn send(self) -> Result, Error> { @@ -23204,7 +23466,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/disks", client.baseurl, @@ -23804,7 +24068,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ImageCreate<'a> { @@ -23813,7 +24077,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ImageCreate::default()), } } @@ -23843,10 +24107,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ImageCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ImageCreate) -> types::builder::ImageCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/images` pub async fn send(self) -> Result, Error> { @@ -23858,7 +24131,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ImageCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/images", client.baseurl, @@ -24240,7 +24515,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> InstanceCreate<'a> { @@ -24249,7 +24524,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceCreate::default()), } } @@ -24279,10 +24554,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances` @@ -24295,7 +24579,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances", client.baseurl, @@ -24693,7 +24979,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceDiskAttach<'a> { @@ -24703,7 +24989,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskIdentifier::default()), } } @@ -24743,10 +25029,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/disks/attach` @@ -24761,7 +25056,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskIdentifier::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/attach", client.baseurl, @@ -24794,7 +25091,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceDiskDetach<'a> { @@ -24804,7 +25101,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskIdentifier::default()), } } @@ -24844,10 +25141,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/disks/detach` @@ -24862,7 +25168,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskIdentifier::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/detach", client.baseurl, @@ -24984,7 +25292,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceMigrate<'a> { @@ -24994,7 +25302,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrate::default()), } } @@ -25034,10 +25342,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/migrate` @@ -25052,7 +25369,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/migrate", client.baseurl, @@ -25278,7 +25597,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceNetworkInterfaceCreate<'a> { @@ -25288,7 +25607,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::NetworkInterfaceCreate::default()), } } @@ -25328,10 +25647,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `NetworkInterfaceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceCreate, + ) -> types::builder::NetworkInterfaceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/network-interfaces` @@ -25348,7 +25678,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::NetworkInterfaceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", client.baseurl, @@ -25486,7 +25818,7 @@ pub mod builder { project_name: Result, instance_name: Result, interface_name: Result, - body: Result, + body: Result, } impl<'a> InstanceNetworkInterfaceUpdate<'a> { @@ -25497,7 +25829,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), interface_name: Err("interface_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::NetworkInterfaceUpdate::default()), } } @@ -25547,10 +25879,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `NetworkInterfaceUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceUpdate, + ) -> types::builder::NetworkInterfaceUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/network-interfaces/{interface_name}` @@ -25569,7 +25912,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; let interface_name = interface_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::NetworkInterfaceUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", client.baseurl, @@ -26279,7 +26624,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ProjectPolicyUpdate<'a> { @@ -26288,7 +26633,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectRolePolicy::default()), } } @@ -26318,10 +26663,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` pub async fn send( @@ -26335,7 +26691,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/policy", client.baseurl, @@ -26543,7 +26901,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> SnapshotCreate<'a> { @@ -26552,7 +26910,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SnapshotCreate::default()), } } @@ -26582,10 +26940,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SnapshotCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SnapshotCreate) -> types::builder::SnapshotCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// snapshots` @@ -26598,7 +26965,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SnapshotCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/snapshots", client.baseurl, @@ -26978,7 +27347,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> VpcCreate<'a> { @@ -26987,7 +27356,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcCreate::default()), } } @@ -27017,10 +27386,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcCreate) -> types::builder::VpcCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` pub async fn send(self) -> Result, Error> { @@ -27032,7 +27410,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs", client.baseurl, @@ -27151,7 +27531,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcUpdate<'a> { @@ -27161,7 +27541,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcUpdate::default()), } } @@ -27201,10 +27581,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcUpdate) -> types::builder::VpcUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}` @@ -27219,7 +27608,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}", client.baseurl, @@ -27428,7 +27819,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcFirewallRulesUpdate<'a> { @@ -27438,7 +27829,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcFirewallRuleUpdateParams::default()), } } @@ -27476,12 +27867,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `VpcFirewallRuleUpdateParams` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::VpcFirewallRuleUpdateParams, + ) -> types::builder::VpcFirewallRuleUpdateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/firewall/rules` @@ -27498,7 +27899,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcFirewallRuleUpdateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", client.baseurl, @@ -27723,7 +28126,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterCreate<'a> { @@ -27733,7 +28136,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcRouterCreate::default()), } } @@ -27773,10 +28176,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcRouterCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterCreate) -> types::builder::VpcRouterCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers` @@ -27791,7 +28203,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcRouterCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers", client.baseurl, @@ -27927,7 +28341,7 @@ pub mod builder { project_name: Result, vpc_name: Result, router_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterUpdate<'a> { @@ -27938,7 +28352,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcRouterUpdate::default()), } } @@ -27988,10 +28402,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcRouterUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterUpdate) -> types::builder::VpcRouterUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}` @@ -28008,7 +28431,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcRouterUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", client.baseurl, @@ -28352,7 +28777,7 @@ pub mod builder { project_name: Result, vpc_name: Result, router_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterRouteCreate<'a> { @@ -28363,7 +28788,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::RouterRouteCreateParams::default()), } } @@ -28413,10 +28838,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `RouterRouteCreateParams` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteCreateParams, + ) -> types::builder::RouterRouteCreateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}/routes` @@ -28433,7 +28869,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::RouterRouteCreateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", client.baseurl, @@ -28586,7 +29024,7 @@ pub mod builder { vpc_name: Result, router_name: Result, route_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterRouteUpdate<'a> { @@ -28598,7 +29036,7 @@ pub mod builder { vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), route_name: Err("route_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::RouterRouteUpdateParams::default()), } } @@ -28658,10 +29096,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `RouterRouteUpdateParams` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteUpdateParams, + ) -> types::builder::RouterRouteUpdateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}/routes/{route_name}` @@ -28680,7 +29129,9 @@ pub mod builder { let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; let route_name = route_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::RouterRouteUpdateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", client.baseurl, @@ -29024,7 +29475,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcSubnetCreate<'a> { @@ -29034,7 +29485,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcSubnetCreate::default()), } } @@ -29074,10 +29525,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcSubnetCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetCreate) -> types::builder::VpcSubnetCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/subnets` @@ -29092,7 +29552,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcSubnetCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets", client.baseurl, @@ -29228,7 +29690,7 @@ pub mod builder { project_name: Result, vpc_name: Result, subnet_name: Result, - body: Result, + body: Result, } impl<'a> VpcSubnetUpdate<'a> { @@ -29239,7 +29701,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), subnet_name: Err("subnet_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcSubnetUpdate::default()), } } @@ -29289,10 +29751,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcSubnetUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetUpdate) -> types::builder::VpcSubnetUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/subnets/{subnet_name}` @@ -29309,7 +29780,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcSubnetUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", client.baseurl, @@ -29685,14 +30158,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct PolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> PolicyUpdate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloRolePolicy::default()), } } @@ -29702,16 +30175,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/policy", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -30221,14 +30705,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SessionSshkeyCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SessionSshkeyCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SshKeyCreate::default()), } } @@ -30238,14 +30722,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SshKeyCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SshKeyCreate) -> types::builder::SshKeyCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/session/me/sshkeys` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SshKeyCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/session/me/sshkeys", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -30675,14 +31170,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct CertificateCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> CertificateCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::CertificateCreate::default()), } } @@ -30692,14 +31187,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::CertificateCreate, + ) -> types::builder::CertificateCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/certificates` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::CertificateCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/certificates", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -31655,14 +32163,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemImageCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemImageCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::GlobalImageCreate::default()), } } @@ -31672,14 +32180,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::GlobalImageCreate, + ) -> types::builder::GlobalImageCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/images` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::GlobalImageCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/images", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -31947,14 +32468,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct IpPoolCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> IpPoolCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::IpPoolCreate::default()), } } @@ -31964,14 +32485,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolCreate) -> types::builder::IpPoolCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/ip-pools` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::IpPoolCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/ip-pools", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -32048,7 +32580,7 @@ pub mod builder { pub struct IpPoolUpdate<'a> { client: &'a super::Client, pool_name: Result, - body: Result, + body: Result, } impl<'a> IpPoolUpdate<'a> { @@ -32056,7 +32588,7 @@ pub mod builder { Self { client, pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::IpPoolUpdate::default()), } } @@ -32076,10 +32608,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolUpdate) -> types::builder::IpPoolUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` pub async fn send(self) -> Result, Error> { let Self { @@ -32088,7 +32629,9 @@ pub mod builder { body, } = self; let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::IpPoolUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/ip-pools/{}", client.baseurl, @@ -32869,14 +33412,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemPolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemPolicyUpdate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::FleetRolePolicy::default()), } } @@ -32886,16 +33429,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FleetRolePolicy) -> types::builder::FleetRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::FleetRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/policy", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -33251,14 +33805,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SiloCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SiloCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloCreate::default()), } } @@ -33268,14 +33822,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloCreate) -> types::builder::SiloCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/silos` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/silos", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -33565,7 +34130,7 @@ pub mod builder { pub struct LocalIdpUserCreate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> LocalIdpUserCreate<'a> { @@ -33573,7 +34138,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UserCreate::default()), } } @@ -33593,10 +34158,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/system/silos/{silo_name}/identity-providers/local/users` pub async fn send(self) -> Result, Error> { @@ -33606,7 +34180,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UserCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/identity-providers/local/users", client.baseurl, @@ -33792,7 +34368,7 @@ pub mod builder { pub struct SamlIdentityProviderCreate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> SamlIdentityProviderCreate<'a> { @@ -33800,7 +34376,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SamlIdentityProviderCreate::default()), } } @@ -33818,12 +34394,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `SamlIdentityProviderCreate` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SamlIdentityProviderCreate, + ) -> types::builder::SamlIdentityProviderCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/system/silos/{silo_name}/identity-providers/saml` pub async fn send( @@ -33835,7 +34421,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SamlIdentityProviderCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/identity-providers/saml", client.baseurl, @@ -33991,7 +34579,7 @@ pub mod builder { pub struct SiloPolicyUpdate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> SiloPolicyUpdate<'a> { @@ -33999,7 +34587,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloRolePolicy::default()), } } @@ -34019,10 +34607,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` pub async fn send( self, @@ -34033,7 +34630,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/policy", client.baseurl, @@ -34924,7 +35523,7 @@ pub mod builder { client: &'a super::Client, organization: Result, String>, project: Result, - body: Result, + body: Result, } impl<'a> DiskCreateV1<'a> { @@ -34933,7 +35532,7 @@ pub mod builder { client, organization: Ok(None), project: Err("project was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskCreate::default()), } } @@ -34964,10 +35563,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/disks` pub async fn send(self) -> Result, Error> { let Self { @@ -34978,7 +35586,9 @@ pub mod builder { } = self; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/disks", client.baseurl,); let mut query = Vec::with_capacity(2usize); if let Some(v) = &organization { @@ -35371,7 +35981,7 @@ pub mod builder { client: &'a super::Client, organization: Result, String>, project: Result, - body: Result, + body: Result, } impl<'a> InstanceCreateV1<'a> { @@ -35380,7 +35990,7 @@ pub mod builder { client, organization: Ok(None), project: Err("project was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceCreate::default()), } } @@ -35411,10 +36021,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances` pub async fn send(self) -> Result, Error> { let Self { @@ -35425,7 +36044,9 @@ pub mod builder { } = self; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/instances", client.baseurl,); let mut query = Vec::with_capacity(2usize); if let Some(v) = &organization { @@ -35837,7 +36458,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceDiskAttachV1<'a> { @@ -35847,7 +36468,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskPath::default()), } } @@ -35889,10 +36510,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` pub async fn send(self) -> Result, Error> { let Self { @@ -35905,7 +36535,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskPath::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/disks/attach", client.baseurl, @@ -35943,7 +36575,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceDiskDetachV1<'a> { @@ -35953,7 +36585,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskPath::default()), } } @@ -35995,10 +36627,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` pub async fn send(self) -> Result, Error> { let Self { @@ -36011,7 +36652,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskPath::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/disks/detach", client.baseurl, @@ -36049,7 +36692,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceMigrateV1<'a> { @@ -36059,7 +36702,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrate::default()), } } @@ -36101,10 +36744,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` pub async fn send(self) -> Result, Error> { let Self { @@ -36117,7 +36769,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/migrate", client.baseurl, @@ -36820,14 +37474,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct OrganizationCreateV1<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> OrganizationCreateV1<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationCreate::default()), } } @@ -36837,14 +37491,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/organizations` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/organizations", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -36924,7 +37591,7 @@ pub mod builder { pub struct OrganizationUpdateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> OrganizationUpdateV1<'a> { @@ -36932,7 +37599,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationUpdate::default()), } } @@ -36952,10 +37619,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/organizations/{organization}` pub async fn send(self) -> Result, Error> { let Self { @@ -36964,7 +37642,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/organizations/{}", client.baseurl, @@ -37105,7 +37785,7 @@ pub mod builder { pub struct OrganizationPolicyUpdateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> OrganizationPolicyUpdateV1<'a> { @@ -37113,7 +37793,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationRolePolicy::default()), } } @@ -37133,10 +37813,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` pub async fn send( self, @@ -37147,7 +37838,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/organizations/{}/policy", client.baseurl, @@ -37335,7 +38028,7 @@ pub mod builder { pub struct ProjectCreateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> ProjectCreateV1<'a> { @@ -37343,7 +38036,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectCreate::default()), } } @@ -37363,10 +38056,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/projects` pub async fn send(self) -> Result, Error> { let Self { @@ -37375,7 +38077,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/projects", client.baseurl,); let mut query = Vec::with_capacity(1usize); query.push(("organization", organization.to_string())); @@ -37477,7 +38181,7 @@ pub mod builder { client: &'a super::Client, project: Result, organization: Result, String>, - body: Result, + body: Result, } impl<'a> ProjectUpdateV1<'a> { @@ -37486,7 +38190,7 @@ pub mod builder { client, project: Err("project was not initialized".to_string()), organization: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectUpdate::default()), } } @@ -37517,10 +38221,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/projects/{project}` pub async fn send(self) -> Result, Error> { let Self { @@ -37531,7 +38244,9 @@ pub mod builder { } = self; let project = project.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/projects/{}", client.baseurl, @@ -37715,7 +38430,7 @@ pub mod builder { client: &'a super::Client, project: Result, organization: Result, String>, - body: Result, + body: Result, } impl<'a> ProjectPolicyUpdateV1<'a> { @@ -37724,7 +38439,7 @@ pub mod builder { client, project: Err("project was not initialized".to_string()), organization: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectRolePolicy::default()), } } @@ -37755,10 +38470,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/projects/{project}/policy` pub async fn send( self, @@ -37771,7 +38497,9 @@ pub mod builder { } = self; let project = project.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/projects/{}/policy", client.baseurl, @@ -38173,14 +38901,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemUpdateStart<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemUpdateStart<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SystemUpdateStart::default()), } } @@ -38190,16 +38918,29 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SystemUpdateStart, + ) -> types::builder::SystemUpdateStart, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/system/update/start` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SystemUpdateStart::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/system/update/start", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out index 3624c81..f9b9685 100644 --- a/progenitor-impl/tests/output/nexus-builder.out +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -6688,7 +6688,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct Baseboard { part: Result, revision: Result, @@ -6759,6 +6760,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Bindouble { count: Result, range: Result, @@ -6815,6 +6817,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Binint64 { count: Result, range: Result, @@ -6871,6 +6874,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Certificate { description: Result, id: Result, @@ -6983,6 +6987,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct CertificateCreate { cert: Result, String>, description: Result, @@ -7081,6 +7086,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct CertificateResultsPage { items: Result, String>, next_page: Result, String>, @@ -7137,6 +7143,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ComponentUpdate { component_type: Result, id: Result, @@ -7235,6 +7242,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ComponentUpdateResultsPage { items: Result, String>, next_page: Result, String>, @@ -7291,6 +7299,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Cumulativedouble { start_time: Result, String>, value: Result, @@ -7347,6 +7356,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Cumulativeint64 { start_time: Result, String>, value: Result, @@ -7403,6 +7413,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DerEncodedKeyPair { private_key: Result, public_cert: Result, @@ -7459,6 +7470,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAccessTokenRequest { client_id: Result, device_code: Result, @@ -7529,6 +7541,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAuthRequest { client_id: Result, } @@ -7571,6 +7584,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DeviceAuthVerify { user_code: Result, } @@ -7613,6 +7627,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Disk { block_size: Result, description: Result, @@ -7809,6 +7824,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskCreate { description: Result, disk_source: Result, @@ -7893,6 +7909,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskIdentifier { name: Result, } @@ -7933,6 +7950,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskPath { disk: Result, } @@ -7973,6 +7991,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -8029,6 +8048,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Distribution { name: Result, version: Result, @@ -8085,6 +8105,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Error { error_code: Result, String>, message: Result, @@ -8155,6 +8176,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ExternalIp { ip: Result, kind: Result, @@ -8211,6 +8233,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ExternalIpResultsPage { items: Result, String>, next_page: Result, String>, @@ -8267,6 +8290,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FieldSchema { name: Result, source: Result, @@ -8337,6 +8361,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FleetRolePolicy { role_assignments: Result, String>, } @@ -8382,6 +8407,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct FleetRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -8452,6 +8478,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImage { block_size: Result, description: Result, @@ -8634,6 +8661,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImageCreate { block_size: Result, description: Result, @@ -8732,6 +8760,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GlobalImageResultsPage { items: Result, String>, next_page: Result, String>, @@ -8788,6 +8817,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Group { display_name: Result, id: Result, @@ -8858,6 +8888,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct GroupResultsPage { items: Result, String>, next_page: Result, String>, @@ -8914,6 +8945,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Histogramdouble { bins: Result, String>, n_samples: Result, @@ -8984,6 +9016,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Histogramint64 { bins: Result, String>, n_samples: Result, @@ -9054,6 +9087,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IdentityProvider { description: Result, id: Result, @@ -9166,6 +9200,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IdentityProviderResultsPage { items: Result, String>, next_page: Result, String>, @@ -9222,6 +9257,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Image { block_size: Result, description: Result, @@ -9404,6 +9440,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ImageCreate { block_size: Result, description: Result, @@ -9488,6 +9525,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ImageResultsPage { items: Result, String>, next_page: Result, String>, @@ -9544,6 +9582,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Instance { description: Result, hostname: Result, @@ -9731,6 +9770,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceCreate { description: Result, disks: Result, String>, @@ -9902,6 +9942,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrate { dst_sled_id: Result, } @@ -9944,6 +9985,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceResultsPage { items: Result, String>, next_page: Result, String>, @@ -10000,6 +10042,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceSerialConsoleData { data: Result, String>, last_byte_offset: Result, @@ -10059,6 +10102,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPool { description: Result, id: Result, @@ -10157,6 +10201,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolCreate { description: Result, name: Result, @@ -10213,6 +10258,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolRange { id: Result, range: Result, @@ -10283,6 +10329,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolRangeResultsPage { items: Result, String>, next_page: Result, String>, @@ -10339,6 +10386,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolResultsPage { items: Result, String>, next_page: Result, String>, @@ -10395,6 +10443,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct IpPoolUpdate { description: Result, String>, name: Result, String>, @@ -10451,6 +10500,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Ipv4Range { first: Result, last: Result, @@ -10507,6 +10557,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Ipv6Range { first: Result, last: Result, @@ -10563,6 +10614,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Measurement { datum: Result, timestamp: Result, String>, @@ -10619,6 +10671,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct MeasurementResultsPage { items: Result, String>, next_page: Result, String>, @@ -10675,6 +10728,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterface { description: Result, id: Result, @@ -10857,6 +10911,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceCreate { description: Result, ip: Result, String>, @@ -10955,6 +11010,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceResultsPage { items: Result, String>, next_page: Result, String>, @@ -11011,6 +11067,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceUpdate { description: Result, String>, name: Result, String>, @@ -11081,6 +11138,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Organization { description: Result, id: Result, @@ -11179,6 +11237,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationCreate { description: Result, name: Result, @@ -11235,6 +11294,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationResultsPage { items: Result, String>, next_page: Result, String>, @@ -11291,6 +11351,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationRolePolicy { role_assignments: Result, String>, } @@ -11336,6 +11397,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -11408,6 +11470,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct OrganizationUpdate { description: Result, String>, name: Result, String>, @@ -11464,6 +11527,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PhysicalDisk { disk_type: Result, id: Result, @@ -11604,6 +11668,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct PhysicalDiskResultsPage { items: Result, String>, next_page: Result, String>, @@ -11660,6 +11725,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Project { description: Result, id: Result, @@ -11772,6 +11838,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectCreate { description: Result, name: Result, @@ -11828,6 +11895,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectResultsPage { items: Result, String>, next_page: Result, String>, @@ -11884,6 +11952,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectRolePolicy { role_assignments: Result, String>, } @@ -11929,6 +11998,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -11999,6 +12069,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct ProjectUpdate { description: Result, String>, name: Result, String>, @@ -12055,6 +12126,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Rack { id: Result, time_created: Result, String>, @@ -12125,6 +12197,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RackResultsPage { items: Result, String>, next_page: Result, String>, @@ -12181,6 +12254,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Role { description: Result, name: Result, @@ -12237,6 +12311,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RoleResultsPage { items: Result, String>, next_page: Result, String>, @@ -12293,6 +12368,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRoute { description: Result, destination: Result, @@ -12447,6 +12523,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteCreateParams { description: Result, destination: Result, @@ -12531,6 +12608,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteResultsPage { items: Result, String>, next_page: Result, String>, @@ -12587,6 +12665,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct RouterRouteUpdateParams { description: Result, String>, destination: Result, @@ -12671,6 +12750,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Saga { id: Result, state: Result, @@ -12727,6 +12807,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SagaResultsPage { items: Result, String>, next_page: Result, String>, @@ -12783,6 +12864,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SamlIdentityProvider { acs_url: Result, description: Result, @@ -12970,6 +13052,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SamlIdentityProviderCreate { acs_url: Result, description: Result, @@ -13151,6 +13234,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Silo { description: Result, discoverable: Result, @@ -13277,6 +13361,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloCreate { admin_group_name: Result, String>, description: Result, @@ -13378,6 +13463,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloResultsPage { items: Result, String>, next_page: Result, String>, @@ -13434,6 +13520,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloRolePolicy { role_assignments: Result, String>, } @@ -13479,6 +13566,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SiloRoleRoleAssignment { identity_id: Result, identity_type: Result, @@ -13549,6 +13637,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Sled { baseboard: Result, id: Result, @@ -13647,6 +13736,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SledResultsPage { items: Result, String>, next_page: Result, String>, @@ -13703,6 +13793,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Snapshot { description: Result, disk_id: Result, @@ -13857,6 +13948,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SnapshotCreate { description: Result, disk: Result, @@ -13927,6 +14019,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SnapshotResultsPage { items: Result, String>, next_page: Result, String>, @@ -13983,6 +14076,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SpoofLoginBody { username: Result, } @@ -14025,6 +14119,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKey { description: Result, id: Result, @@ -14151,6 +14246,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKeyCreate { description: Result, name: Result, @@ -14221,6 +14317,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SshKeyResultsPage { items: Result, String>, next_page: Result, String>, @@ -14277,6 +14374,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdate { id: Result, time_created: Result, String>, @@ -14361,6 +14459,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdateResultsPage { items: Result, String>, next_page: Result, String>, @@ -14417,6 +14516,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemUpdateStart { version: Result, } @@ -14459,6 +14559,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct SystemVersion { status: Result, version_range: Result, @@ -14515,6 +14616,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TimeseriesSchema { created: Result, String>, datum_type: Result, @@ -14599,6 +14701,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct TimeseriesSchemaResultsPage { items: Result, String>, next_page: Result, String>, @@ -14655,6 +14758,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateDeployment { id: Result, status: Result, @@ -14753,6 +14857,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateDeploymentResultsPage { items: Result, String>, next_page: Result, String>, @@ -14809,6 +14914,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateableComponent { component_type: Result, device_id: Result, @@ -14949,6 +15055,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UpdateableComponentResultsPage { items: Result, String>, next_page: Result, String>, @@ -15007,6 +15114,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct User { display_name: Result, id: Result, @@ -15077,6 +15185,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserBuiltin { description: Result, id: Result, @@ -15175,6 +15284,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserBuiltinResultsPage { items: Result, String>, next_page: Result, String>, @@ -15231,6 +15341,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserCreate { external_id: Result, password: Result, @@ -15287,6 +15398,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UserResultsPage { items: Result, String>, next_page: Result, String>, @@ -15343,6 +15455,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct UsernamePasswordCredentials { password: Result, username: Result, @@ -15399,6 +15512,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VersionRange { high: Result, low: Result, @@ -15455,6 +15569,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Vpc { description: Result, dns_name: Result, @@ -15612,6 +15727,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcCreate { description: Result, dns_name: Result, @@ -15696,6 +15812,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRule { action: Result, description: Result, @@ -15892,6 +16009,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleFilter { hosts: Result>, String>, ports: Result>, String>, @@ -15962,6 +16080,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleUpdate { action: Result, description: Result, @@ -16102,6 +16221,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRuleUpdateParams { rules: Result, String>, } @@ -16144,6 +16264,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcFirewallRules { rules: Result, String>, } @@ -16186,6 +16307,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcResultsPage { items: Result, String>, next_page: Result, String>, @@ -16242,6 +16364,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouter { description: Result, id: Result, @@ -16368,6 +16491,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterCreate { description: Result, name: Result, @@ -16424,6 +16548,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterResultsPage { items: Result, String>, next_page: Result, String>, @@ -16480,6 +16605,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcRouterUpdate { description: Result, String>, name: Result, String>, @@ -16536,6 +16662,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnet { description: Result, id: Result, @@ -16676,6 +16803,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetCreate { description: Result, ipv4_block: Result, @@ -16760,6 +16888,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetResultsPage { items: Result, String>, next_page: Result, String>, @@ -16816,6 +16945,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcSubnetUpdate { description: Result, String>, name: Result, String>, @@ -16872,6 +17002,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct VpcUpdate { description: Result, String>, dns_name: Result, String>, @@ -16943,7 +17074,7 @@ pub mod types { } } - mod defaults { + pub mod defaults { pub(super) fn default_bool() -> bool { V } @@ -21229,14 +21360,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAuthRequest<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAuthRequest<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAuthRequest::default()), } } @@ -21246,14 +21377,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DeviceAuthRequest` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthRequest, + ) -> types::builder::DeviceAuthRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/auth` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAuthRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/auth", client.baseurl,); let request = client.client.post(url).form_urlencoded(&body)?.build()?; let result = client.client.execute(request).await; @@ -21271,14 +21415,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAuthConfirm<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAuthConfirm<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAuthVerify::default()), } } @@ -21288,14 +21432,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DeviceAuthVerify` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAuthVerify, + ) -> types::builder::DeviceAuthVerify, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/confirm` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAuthVerify::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/confirm", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -21319,14 +21476,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DeviceAccessToken<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DeviceAccessToken<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DeviceAccessTokenRequest::default()), } } @@ -21334,16 +21491,28 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `DeviceAccessTokenRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::DeviceAccessTokenRequest, + ) -> types::builder::DeviceAccessTokenRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/device/token` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DeviceAccessTokenRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/device/token", client.baseurl,); let request = client.client.post(url).form_urlencoded(&body)?.build()?; let result = client.client.execute(request).await; @@ -21501,14 +21670,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct LoginSpoof<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> LoginSpoof<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SpoofLoginBody::default()), } } @@ -21518,14 +21687,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SpoofLoginBody` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SpoofLoginBody) -> types::builder::SpoofLoginBody, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/login` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SpoofLoginBody::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/login", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -21550,7 +21730,7 @@ pub mod builder { pub struct LoginLocal<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> LoginLocal<'a> { @@ -21558,7 +21738,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UsernamePasswordCredentials::default()), } } @@ -21576,12 +21756,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `UsernamePasswordCredentials` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::UsernamePasswordCredentials, + ) -> types::builder::UsernamePasswordCredentials, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/login/{silo_name}/local` pub async fn send(self) -> Result, Error> { let Self { @@ -21590,7 +21780,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UsernamePasswordCredentials::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/login/{}/local", client.baseurl, @@ -21953,14 +22145,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct OrganizationCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> OrganizationCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationCreate::default()), } } @@ -21970,14 +22162,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/organizations` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/organizations", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -22057,7 +22262,7 @@ pub mod builder { pub struct OrganizationUpdate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> OrganizationUpdate<'a> { @@ -22065,7 +22270,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationUpdate::default()), } } @@ -22085,10 +22290,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/organizations/{organization_name}` pub async fn send(self) -> Result, Error> { let Self { @@ -22097,7 +22313,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}", client.baseurl, @@ -22238,7 +22456,7 @@ pub mod builder { pub struct OrganizationPolicyUpdate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> OrganizationPolicyUpdate<'a> { @@ -22246,7 +22464,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationRolePolicy::default()), } } @@ -22266,10 +22484,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/organizations/{organization_name}/policy` pub async fn send( self, @@ -22280,7 +22509,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/policy", client.baseurl, @@ -22469,7 +22700,7 @@ pub mod builder { pub struct ProjectCreate<'a> { client: &'a super::Client, organization_name: Result, - body: Result, + body: Result, } impl<'a> ProjectCreate<'a> { @@ -22477,7 +22708,7 @@ pub mod builder { Self { client, organization_name: Err("organization_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectCreate::default()), } } @@ -22497,10 +22728,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects` pub async fn send(self) -> Result, Error> { @@ -22510,7 +22750,9 @@ pub mod builder { body, } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects", client.baseurl, @@ -22611,7 +22853,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ProjectUpdate<'a> { @@ -22620,7 +22862,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectUpdate::default()), } } @@ -22650,10 +22892,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}` pub async fn send(self) -> Result, Error> { @@ -22665,7 +22916,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}", client.baseurl, @@ -22942,7 +23195,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> DiskCreate<'a> { @@ -22951,7 +23204,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskCreate::default()), } } @@ -22981,10 +23234,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/disks` pub async fn send(self) -> Result, Error> { @@ -22996,7 +23258,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/disks", client.baseurl, @@ -23596,7 +23860,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ImageCreate<'a> { @@ -23605,7 +23869,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ImageCreate::default()), } } @@ -23635,10 +23899,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ImageCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ImageCreate) -> types::builder::ImageCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/images` pub async fn send(self) -> Result, Error> { @@ -23650,7 +23923,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ImageCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/images", client.baseurl, @@ -24032,7 +24307,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> InstanceCreate<'a> { @@ -24041,7 +24316,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceCreate::default()), } } @@ -24071,10 +24346,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances` @@ -24087,7 +24371,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances", client.baseurl, @@ -24485,7 +24771,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceDiskAttach<'a> { @@ -24495,7 +24781,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskIdentifier::default()), } } @@ -24535,10 +24821,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/disks/attach` @@ -24553,7 +24848,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskIdentifier::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/attach", client.baseurl, @@ -24586,7 +24883,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceDiskDetach<'a> { @@ -24596,7 +24893,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskIdentifier::default()), } } @@ -24636,10 +24933,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskIdentifier` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskIdentifier) -> types::builder::DiskIdentifier, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/disks/detach` @@ -24654,7 +24960,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskIdentifier::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/disks/detach", client.baseurl, @@ -24776,7 +25084,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceMigrate<'a> { @@ -24786,7 +25094,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrate::default()), } } @@ -24826,10 +25134,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/migrate` @@ -24844,7 +25161,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/migrate", client.baseurl, @@ -25070,7 +25389,7 @@ pub mod builder { organization_name: Result, project_name: Result, instance_name: Result, - body: Result, + body: Result, } impl<'a> InstanceNetworkInterfaceCreate<'a> { @@ -25080,7 +25399,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::NetworkInterfaceCreate::default()), } } @@ -25120,10 +25439,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `NetworkInterfaceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceCreate, + ) -> types::builder::NetworkInterfaceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/network-interfaces` @@ -25140,7 +25470,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::NetworkInterfaceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces", client.baseurl, @@ -25278,7 +25610,7 @@ pub mod builder { project_name: Result, instance_name: Result, interface_name: Result, - body: Result, + body: Result, } impl<'a> InstanceNetworkInterfaceUpdate<'a> { @@ -25289,7 +25621,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), instance_name: Err("instance_name was not initialized".to_string()), interface_name: Err("interface_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::NetworkInterfaceUpdate::default()), } } @@ -25339,10 +25671,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `NetworkInterfaceUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::NetworkInterfaceUpdate, + ) -> types::builder::NetworkInterfaceUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// instances/{instance_name}/network-interfaces/{interface_name}` @@ -25361,7 +25704,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let instance_name = instance_name.map_err(Error::InvalidRequest)?; let interface_name = interface_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::NetworkInterfaceUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/instances/{}/network-interfaces/{}", client.baseurl, @@ -26071,7 +26416,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> ProjectPolicyUpdate<'a> { @@ -26080,7 +26425,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectRolePolicy::default()), } } @@ -26110,10 +26455,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/policy` pub async fn send( @@ -26127,7 +26483,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/policy", client.baseurl, @@ -26335,7 +26693,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> SnapshotCreate<'a> { @@ -26344,7 +26702,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SnapshotCreate::default()), } } @@ -26374,10 +26732,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SnapshotCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SnapshotCreate) -> types::builder::SnapshotCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/ /// snapshots` @@ -26390,7 +26757,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SnapshotCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/snapshots", client.baseurl, @@ -26770,7 +27139,7 @@ pub mod builder { client: &'a super::Client, organization_name: Result, project_name: Result, - body: Result, + body: Result, } impl<'a> VpcCreate<'a> { @@ -26779,7 +27148,7 @@ pub mod builder { client, organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcCreate::default()), } } @@ -26809,10 +27178,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcCreate) -> types::builder::VpcCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs` pub async fn send(self) -> Result, Error> { @@ -26824,7 +27202,9 @@ pub mod builder { } = self; let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs", client.baseurl, @@ -26943,7 +27323,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcUpdate<'a> { @@ -26953,7 +27333,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcUpdate::default()), } } @@ -26993,10 +27373,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcUpdate) -> types::builder::VpcUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}` @@ -27011,7 +27400,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}", client.baseurl, @@ -27220,7 +27611,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcFirewallRulesUpdate<'a> { @@ -27230,7 +27621,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcFirewallRuleUpdateParams::default()), } } @@ -27268,12 +27659,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `VpcFirewallRuleUpdateParams` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::VpcFirewallRuleUpdateParams, + ) -> types::builder::VpcFirewallRuleUpdateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/firewall/rules` @@ -27290,7 +27691,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcFirewallRuleUpdateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/firewall/rules", client.baseurl, @@ -27515,7 +27918,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterCreate<'a> { @@ -27525,7 +27928,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcRouterCreate::default()), } } @@ -27565,10 +27968,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcRouterCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterCreate) -> types::builder::VpcRouterCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers` @@ -27583,7 +27995,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcRouterCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers", client.baseurl, @@ -27719,7 +28133,7 @@ pub mod builder { project_name: Result, vpc_name: Result, router_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterUpdate<'a> { @@ -27730,7 +28144,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcRouterUpdate::default()), } } @@ -27780,10 +28194,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcRouterUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcRouterUpdate) -> types::builder::VpcRouterUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}` @@ -27800,7 +28223,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcRouterUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}", client.baseurl, @@ -28144,7 +28569,7 @@ pub mod builder { project_name: Result, vpc_name: Result, router_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterRouteCreate<'a> { @@ -28155,7 +28580,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::RouterRouteCreateParams::default()), } } @@ -28205,10 +28630,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `RouterRouteCreateParams` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteCreateParams, + ) -> types::builder::RouterRouteCreateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}/routes` @@ -28225,7 +28661,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::RouterRouteCreateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes", client.baseurl, @@ -28378,7 +28816,7 @@ pub mod builder { vpc_name: Result, router_name: Result, route_name: Result, - body: Result, + body: Result, } impl<'a> VpcRouterRouteUpdate<'a> { @@ -28390,7 +28828,7 @@ pub mod builder { vpc_name: Err("vpc_name was not initialized".to_string()), router_name: Err("router_name was not initialized".to_string()), route_name: Err("route_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::RouterRouteUpdateParams::default()), } } @@ -28450,10 +28888,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `RouterRouteUpdateParams` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::RouterRouteUpdateParams, + ) -> types::builder::RouterRouteUpdateParams, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/routers/{router_name}/routes/{route_name}` @@ -28472,7 +28921,9 @@ pub mod builder { let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let router_name = router_name.map_err(Error::InvalidRequest)?; let route_name = route_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::RouterRouteUpdateParams::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/routers/{}/routes/{}", client.baseurl, @@ -28816,7 +29267,7 @@ pub mod builder { organization_name: Result, project_name: Result, vpc_name: Result, - body: Result, + body: Result, } impl<'a> VpcSubnetCreate<'a> { @@ -28826,7 +29277,7 @@ pub mod builder { organization_name: Err("organization_name was not initialized".to_string()), project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcSubnetCreate::default()), } } @@ -28866,10 +29317,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcSubnetCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetCreate) -> types::builder::VpcSubnetCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/subnets` @@ -28884,7 +29344,9 @@ pub mod builder { let organization_name = organization_name.map_err(Error::InvalidRequest)?; let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcSubnetCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets", client.baseurl, @@ -29020,7 +29482,7 @@ pub mod builder { project_name: Result, vpc_name: Result, subnet_name: Result, - body: Result, + body: Result, } impl<'a> VpcSubnetUpdate<'a> { @@ -29031,7 +29493,7 @@ pub mod builder { project_name: Err("project_name was not initialized".to_string()), vpc_name: Err("vpc_name was not initialized".to_string()), subnet_name: Err("subnet_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::VpcSubnetUpdate::default()), } } @@ -29081,10 +29543,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `VpcSubnetUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::VpcSubnetUpdate) -> types::builder::VpcSubnetUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to /// `/organizations/{organization_name}/projects/{project_name}/vpcs/ /// {vpc_name}/subnets/{subnet_name}` @@ -29101,7 +29572,9 @@ pub mod builder { let project_name = project_name.map_err(Error::InvalidRequest)?; let vpc_name = vpc_name.map_err(Error::InvalidRequest)?; let subnet_name = subnet_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::VpcSubnetUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/organizations/{}/projects/{}/vpcs/{}/subnets/{}", client.baseurl, @@ -29477,14 +29950,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct PolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> PolicyUpdate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloRolePolicy::default()), } } @@ -29494,16 +29967,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/policy", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -30013,14 +30497,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SessionSshkeyCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SessionSshkeyCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SshKeyCreate::default()), } } @@ -30030,14 +30514,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SshKeyCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SshKeyCreate) -> types::builder::SshKeyCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/session/me/sshkeys` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SshKeyCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/session/me/sshkeys", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -30467,14 +30962,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct CertificateCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> CertificateCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::CertificateCreate::default()), } } @@ -30484,14 +30979,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `CertificateCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::CertificateCreate, + ) -> types::builder::CertificateCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/certificates` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::CertificateCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/certificates", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -31447,14 +31955,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemImageCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemImageCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::GlobalImageCreate::default()), } } @@ -31464,14 +31972,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `GlobalImageCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::GlobalImageCreate, + ) -> types::builder::GlobalImageCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/images` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::GlobalImageCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/images", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -31739,14 +32260,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct IpPoolCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> IpPoolCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::IpPoolCreate::default()), } } @@ -31756,14 +32277,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `IpPoolCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolCreate) -> types::builder::IpPoolCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/ip-pools` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::IpPoolCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/ip-pools", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -31840,7 +32372,7 @@ pub mod builder { pub struct IpPoolUpdate<'a> { client: &'a super::Client, pool_name: Result, - body: Result, + body: Result, } impl<'a> IpPoolUpdate<'a> { @@ -31848,7 +32380,7 @@ pub mod builder { Self { client, pool_name: Err("pool_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::IpPoolUpdate::default()), } } @@ -31868,10 +32400,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `IpPoolUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::IpPoolUpdate) -> types::builder::IpPoolUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/ip-pools/{pool_name}` pub async fn send(self) -> Result, Error> { let Self { @@ -31880,7 +32421,9 @@ pub mod builder { body, } = self; let pool_name = pool_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::IpPoolUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/ip-pools/{}", client.baseurl, @@ -32661,14 +33204,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemPolicyUpdate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemPolicyUpdate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::FleetRolePolicy::default()), } } @@ -32678,16 +33221,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `FleetRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::FleetRolePolicy) -> types::builder::FleetRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/policy` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::FleetRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/policy", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -33043,14 +33597,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SiloCreate<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SiloCreate<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloCreate::default()), } } @@ -33060,14 +33614,25 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloCreate) -> types::builder::SiloCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/system/silos` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/system/silos", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -33357,7 +33922,7 @@ pub mod builder { pub struct LocalIdpUserCreate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> LocalIdpUserCreate<'a> { @@ -33365,7 +33930,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::UserCreate::default()), } } @@ -33385,10 +33950,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `UserCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::UserCreate) -> types::builder::UserCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/system/silos/{silo_name}/identity-providers/local/users` pub async fn send(self) -> Result, Error> { @@ -33398,7 +33972,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::UserCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/identity-providers/local/users", client.baseurl, @@ -33584,7 +34160,7 @@ pub mod builder { pub struct SamlIdentityProviderCreate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> SamlIdentityProviderCreate<'a> { @@ -33592,7 +34168,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SamlIdentityProviderCreate::default()), } } @@ -33610,12 +34186,22 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `SamlIdentityProviderCreate` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SamlIdentityProviderCreate, + ) -> types::builder::SamlIdentityProviderCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to /// `/system/silos/{silo_name}/identity-providers/saml` pub async fn send( @@ -33627,7 +34213,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SamlIdentityProviderCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/identity-providers/saml", client.baseurl, @@ -33783,7 +34371,7 @@ pub mod builder { pub struct SiloPolicyUpdate<'a> { client: &'a super::Client, silo_name: Result, - body: Result, + body: Result, } impl<'a> SiloPolicyUpdate<'a> { @@ -33791,7 +34379,7 @@ pub mod builder { Self { client, silo_name: Err("silo_name was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SiloRolePolicy::default()), } } @@ -33811,10 +34399,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SiloRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::SiloRolePolicy) -> types::builder::SiloRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/system/silos/{silo_name}/policy` pub async fn send( self, @@ -33825,7 +34422,9 @@ pub mod builder { body, } = self; let silo_name = silo_name.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SiloRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/system/silos/{}/policy", client.baseurl, @@ -34716,7 +35315,7 @@ pub mod builder { client: &'a super::Client, organization: Result, String>, project: Result, - body: Result, + body: Result, } impl<'a> DiskCreateV1<'a> { @@ -34725,7 +35324,7 @@ pub mod builder { client, organization: Ok(None), project: Err("project was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskCreate::default()), } } @@ -34756,10 +35355,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskCreate) -> types::builder::DiskCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/disks` pub async fn send(self) -> Result, Error> { let Self { @@ -34770,7 +35378,9 @@ pub mod builder { } = self; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/disks", client.baseurl,); let mut query = Vec::with_capacity(2usize); if let Some(v) = &organization { @@ -35163,7 +35773,7 @@ pub mod builder { client: &'a super::Client, organization: Result, String>, project: Result, - body: Result, + body: Result, } impl<'a> InstanceCreateV1<'a> { @@ -35172,7 +35782,7 @@ pub mod builder { client, organization: Ok(None), project: Err("project was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceCreate::default()), } } @@ -35203,10 +35813,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceCreate) -> types::builder::InstanceCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances` pub async fn send(self) -> Result, Error> { let Self { @@ -35217,7 +35836,9 @@ pub mod builder { } = self; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/instances", client.baseurl,); let mut query = Vec::with_capacity(2usize); if let Some(v) = &organization { @@ -35629,7 +36250,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceDiskAttachV1<'a> { @@ -35639,7 +36260,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskPath::default()), } } @@ -35681,10 +36302,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/disks/attach` pub async fn send(self) -> Result, Error> { let Self { @@ -35697,7 +36327,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskPath::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/disks/attach", client.baseurl, @@ -35735,7 +36367,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceDiskDetachV1<'a> { @@ -35745,7 +36377,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::DiskPath::default()), } } @@ -35787,10 +36419,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `DiskPath` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::DiskPath) -> types::builder::DiskPath, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/disks/detach` pub async fn send(self) -> Result, Error> { let Self { @@ -35803,7 +36444,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::DiskPath::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/disks/detach", client.baseurl, @@ -35841,7 +36484,7 @@ pub mod builder { instance: Result, organization: Result, String>, project: Result, String>, - body: Result, + body: Result, } impl<'a> InstanceMigrateV1<'a> { @@ -35851,7 +36494,7 @@ pub mod builder { instance: Err("instance was not initialized".to_string()), organization: Ok(None), project: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrate::default()), } } @@ -35893,10 +36536,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceMigrate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::InstanceMigrate) -> types::builder::InstanceMigrate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/instances/{instance}/migrate` pub async fn send(self) -> Result, Error> { let Self { @@ -35909,7 +36561,9 @@ pub mod builder { let instance = instance.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; let project = project.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/instances/{}/migrate", client.baseurl, @@ -36612,14 +37266,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct OrganizationCreateV1<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> OrganizationCreateV1<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationCreate::default()), } } @@ -36629,14 +37283,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationCreate, + ) -> types::builder::OrganizationCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/organizations` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/organizations", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -36716,7 +37383,7 @@ pub mod builder { pub struct OrganizationUpdateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> OrganizationUpdateV1<'a> { @@ -36724,7 +37391,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationUpdate::default()), } } @@ -36744,10 +37411,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationUpdate, + ) -> types::builder::OrganizationUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/organizations/{organization}` pub async fn send(self) -> Result, Error> { let Self { @@ -36756,7 +37434,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/organizations/{}", client.baseurl, @@ -36897,7 +37577,7 @@ pub mod builder { pub struct OrganizationPolicyUpdateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> OrganizationPolicyUpdateV1<'a> { @@ -36905,7 +37585,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::OrganizationRolePolicy::default()), } } @@ -36925,10 +37605,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `OrganizationRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::OrganizationRolePolicy, + ) -> types::builder::OrganizationRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/organizations/{organization}/policy` pub async fn send( self, @@ -36939,7 +37630,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::OrganizationRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/organizations/{}/policy", client.baseurl, @@ -37127,7 +37820,7 @@ pub mod builder { pub struct ProjectCreateV1<'a> { client: &'a super::Client, organization: Result, - body: Result, + body: Result, } impl<'a> ProjectCreateV1<'a> { @@ -37135,7 +37828,7 @@ pub mod builder { Self { client, organization: Err("organization was not initialized".to_string()), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectCreate::default()), } } @@ -37155,10 +37848,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectCreate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectCreate) -> types::builder::ProjectCreate, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/projects` pub async fn send(self) -> Result, Error> { let Self { @@ -37167,7 +37869,9 @@ pub mod builder { body, } = self; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectCreate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/projects", client.baseurl,); let mut query = Vec::with_capacity(1usize); query.push(("organization", organization.to_string())); @@ -37269,7 +37973,7 @@ pub mod builder { client: &'a super::Client, project: Result, organization: Result, String>, - body: Result, + body: Result, } impl<'a> ProjectUpdateV1<'a> { @@ -37278,7 +37982,7 @@ pub mod builder { client, project: Err("project was not initialized".to_string()), organization: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectUpdate::default()), } } @@ -37309,10 +38013,19 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectUpdate` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::ProjectUpdate) -> types::builder::ProjectUpdate, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/projects/{project}` pub async fn send(self) -> Result, Error> { let Self { @@ -37323,7 +38036,9 @@ pub mod builder { } = self; let project = project.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectUpdate::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/projects/{}", client.baseurl, @@ -37507,7 +38222,7 @@ pub mod builder { client: &'a super::Client, project: Result, organization: Result, String>, - body: Result, + body: Result, } impl<'a> ProjectPolicyUpdateV1<'a> { @@ -37516,7 +38231,7 @@ pub mod builder { client, project: Err("project was not initialized".to_string()), organization: Ok(None), - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::ProjectRolePolicy::default()), } } @@ -37547,10 +38262,21 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `ProjectRolePolicy` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::ProjectRolePolicy, + ) -> types::builder::ProjectRolePolicy, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/v1/projects/{project}/policy` pub async fn send( self, @@ -37563,7 +38289,9 @@ pub mod builder { } = self; let project = project.map_err(Error::InvalidRequest)?; let organization = organization.map_err(Error::InvalidRequest)?; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::ProjectRolePolicy::try_from) + .map_err(Error::InvalidRequest)?; let url = format!( "{}/v1/projects/{}/policy", client.baseurl, @@ -37965,14 +38693,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct SystemUpdateStart<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> SystemUpdateStart<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::SystemUpdateStart::default()), } } @@ -37982,16 +38710,29 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `SystemUpdateStart` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::SystemUpdateStart, + ) -> types::builder::SystemUpdateStart, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/v1/system/update/start` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::SystemUpdateStart::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/v1/system/update/start", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; diff --git a/progenitor-impl/tests/output/nexus-positional.out b/progenitor-impl/tests/output/nexus-positional.out index ef587b1..a380cb2 100644 --- a/progenitor-impl/tests/output/nexus-positional.out +++ b/progenitor-impl/tests/output/nexus-positional.out @@ -5846,7 +5846,7 @@ pub mod types { } } - mod defaults { + pub mod defaults { pub(super) fn default_bool() -> bool { V } diff --git a/progenitor-impl/tests/output/propolis-server-builder-tagged.out b/progenitor-impl/tests/output/propolis-server-builder-tagged.out index 4cfb01d..e80130f 100644 --- a/progenitor-impl/tests/output/propolis-server-builder-tagged.out +++ b/progenitor-impl/tests/output/propolis-server-builder-tagged.out @@ -705,7 +705,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct CrucibleOpts { cert_pem: Result, String>, control: Result, String>, @@ -874,6 +875,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskAttachment { disk_id: Result, generation_id: Result, @@ -944,6 +946,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskRequest { device: Result, gen: Result, @@ -1061,6 +1064,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Error { error_code: Result, String>, message: Result, @@ -1131,6 +1135,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Instance { disks: Result, String>, nics: Result, String>, @@ -1215,6 +1220,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceEnsureRequest { cloud_init_bytes: Result, String>, disks: Result, String>, @@ -1316,6 +1322,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceEnsureResponse { migrate: Result, String>, } @@ -1358,6 +1365,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceGetResponse { instance: Result, } @@ -1400,6 +1408,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateInitiateRequest { migration_id: Result, src_addr: Result, @@ -1472,6 +1481,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateInitiateResponse { migration_id: Result, } @@ -1516,6 +1526,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateStatusRequest { migration_id: Result, } @@ -1558,6 +1569,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateStatusResponse { state: Result, } @@ -1600,6 +1612,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceProperties { bootrom_id: Result, description: Result, @@ -1726,6 +1739,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceStateMonitorRequest { gen: Result, } @@ -1764,6 +1778,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceStateMonitorResponse { gen: Result, state: Result, @@ -1820,6 +1835,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterface { attachment: Result, name: Result, @@ -1876,6 +1892,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceRequest { name: Result, slot: Result, @@ -2119,14 +2136,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceEnsure<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceEnsure<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceEnsureRequest::default()), } } @@ -2136,16 +2153,29 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceEnsureRequest` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceEnsureRequest, + ) -> types::builder::InstanceEnsureRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/instance` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceEnsureRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2240,14 +2270,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceMigrateStatus<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceMigrateStatus<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrateStatusRequest::default()), } } @@ -2255,19 +2285,31 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `InstanceMigrateStatusRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceMigrateStatusRequest, + ) -> types::builder::InstanceMigrateStatusRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `GET` request to `/instance/migrate/status` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrateStatusRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance/migrate/status", client.baseurl,); let request = client.client.get(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2382,14 +2424,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceStateMonitor<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceStateMonitor<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceStateMonitorRequest::default()), } } @@ -2397,19 +2439,31 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `InstanceStateMonitorRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceStateMonitorRequest, + ) -> types::builder::InstanceStateMonitorRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `GET` request to `/instance/state-monitor` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceStateMonitorRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance/state-monitor", client.baseurl,); let request = client.client.get(url).json(&body).build()?; let result = client.client.execute(request).await; diff --git a/progenitor-impl/tests/output/propolis-server-builder.out b/progenitor-impl/tests/output/propolis-server-builder.out index 88ae926..ba1f83c 100644 --- a/progenitor-impl/tests/output/propolis-server-builder.out +++ b/progenitor-impl/tests/output/propolis-server-builder.out @@ -711,7 +711,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct CrucibleOpts { cert_pem: Result, String>, control: Result, String>, @@ -880,6 +881,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskAttachment { disk_id: Result, generation_id: Result, @@ -950,6 +952,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct DiskRequest { device: Result, gen: Result, @@ -1067,6 +1070,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Error { error_code: Result, String>, message: Result, @@ -1137,6 +1141,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Instance { disks: Result, String>, nics: Result, String>, @@ -1221,6 +1226,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceEnsureRequest { cloud_init_bytes: Result, String>, disks: Result, String>, @@ -1322,6 +1328,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceEnsureResponse { migrate: Result, String>, } @@ -1364,6 +1371,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceGetResponse { instance: Result, } @@ -1406,6 +1414,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateInitiateRequest { migration_id: Result, src_addr: Result, @@ -1478,6 +1487,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateInitiateResponse { migration_id: Result, } @@ -1522,6 +1532,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateStatusRequest { migration_id: Result, } @@ -1564,6 +1575,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceMigrateStatusResponse { state: Result, } @@ -1606,6 +1618,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceProperties { bootrom_id: Result, description: Result, @@ -1732,6 +1745,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceStateMonitorRequest { gen: Result, } @@ -1770,6 +1784,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct InstanceStateMonitorResponse { gen: Result, state: Result, @@ -1826,6 +1841,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterface { attachment: Result, name: Result, @@ -1882,6 +1898,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct NetworkInterfaceRequest { name: Result, slot: Result, @@ -2125,14 +2142,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceEnsure<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceEnsure<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceEnsureRequest::default()), } } @@ -2142,16 +2159,29 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `InstanceEnsureRequest` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceEnsureRequest, + ) -> types::builder::InstanceEnsureRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `PUT` request to `/instance` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceEnsureRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance", client.baseurl,); let request = client.client.put(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2246,14 +2276,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceMigrateStatus<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceMigrateStatus<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceMigrateStatusRequest::default()), } } @@ -2261,19 +2291,31 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `InstanceMigrateStatusRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceMigrateStatusRequest, + ) -> types::builder::InstanceMigrateStatusRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `GET` request to `/instance/migrate/status` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceMigrateStatusRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance/migrate/status", client.baseurl,); let request = client.client.get(url).json(&body).build()?; let result = client.client.execute(request).await; @@ -2388,14 +2430,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct InstanceStateMonitor<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> InstanceStateMonitor<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::InstanceStateMonitorRequest::default()), } } @@ -2403,19 +2445,31 @@ pub mod builder { where V: std::convert::TryInto, { - self.body = value.try_into().map_err(|_| { + self.body = value.try_into().map(From::from).map_err(|_| { "conversion to `InstanceStateMonitorRequest` for body failed".to_string() }); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::InstanceStateMonitorRequest, + ) -> types::builder::InstanceStateMonitorRequest, + { + self.body = self.body.map(f); + self + } + ///Sends a `GET` request to `/instance/state-monitor` pub async fn send( self, ) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::InstanceStateMonitorRequest::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/instance/state-monitor", client.baseurl,); let request = client.client.get(url).json(&body).build()?; let result = client.client.execute(request).await; diff --git a/progenitor-impl/tests/output/test_default_params_builder.out b/progenitor-impl/tests/output/test_default_params_builder.out index c5c6439..c6b781c 100644 --- a/progenitor-impl/tests/output/test_default_params_builder.out +++ b/progenitor-impl/tests/output/test_default_params_builder.out @@ -51,7 +51,8 @@ pub mod types { } } - mod builder { + pub mod builder { + #[derive(Clone, Debug)] pub struct BodyWithDefaults { forty_two: Result, s: Result, @@ -136,6 +137,7 @@ pub mod types { } } + #[derive(Clone, Debug)] pub struct Error { error_code: Result, String>, message: Result, @@ -207,7 +209,7 @@ pub mod types { } } - mod defaults { + pub mod defaults { pub(super) fn default_u64() -> T where T: std::convert::TryFrom, @@ -295,14 +297,14 @@ pub mod builder { #[derive(Debug, Clone)] pub struct DefaultParams<'a> { client: &'a super::Client, - body: Result, + body: Result, } impl<'a> DefaultParams<'a> { pub fn new(client: &'a super::Client) -> Self { Self { client, - body: Err("body was not initialized".to_string()), + body: Ok(types::builder::BodyWithDefaults::default()), } } @@ -312,14 +314,27 @@ pub mod builder { { self.body = value .try_into() + .map(From::from) .map_err(|_| "conversion to `BodyWithDefaults` for body failed".to_string()); self } + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce( + types::builder::BodyWithDefaults, + ) -> types::builder::BodyWithDefaults, + { + self.body = self.body.map(f); + self + } + ///Sends a `POST` request to `/` pub async fn send(self) -> Result, Error> { let Self { client, body } = self; - let body = body.map_err(Error::InvalidRequest)?; + let body = body + .and_then(types::BodyWithDefaults::try_from) + .map_err(Error::InvalidRequest)?; let url = format!("{}/", client.baseurl,); let request = client.client.post(url).json(&body).build()?; let result = client.client.execute(request).await; diff --git a/progenitor-impl/tests/output/test_default_params_positional.out b/progenitor-impl/tests/output/test_default_params_positional.out index efcbed3..3544fe7 100644 --- a/progenitor-impl/tests/output/test_default_params_positional.out +++ b/progenitor-impl/tests/output/test_default_params_positional.out @@ -39,7 +39,7 @@ pub mod types { } } - mod defaults { + pub mod defaults { pub(super) fn default_u64() -> T where T: std::convert::TryFrom,