allow request mutation and async code in prehooks (#457)

This commit is contained in:
Joshua M. Clulow 2024-02-04 11:19:07 -08:00 committed by GitHub
parent a58f336c25
commit 3ff2ec1d5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 1412 additions and 683 deletions

View File

@ -8,10 +8,27 @@ generate_api!(
pre_hook = (|_, request| { pre_hook = (|_, request| {
println!("doing this {:?}", request); println!("doing this {:?}", request);
}), }),
pre_hook_async = crate::add_auth_headers,
post_hook = crate::all_done, post_hook = crate::all_done,
derives = [schemars::JsonSchema], derives = [schemars::JsonSchema],
); );
async fn add_auth_headers(
_: &(),
req: &mut reqwest::Request,
) -> Result<(), reqwest::header::InvalidHeaderValue> {
// You can perform asynchronous, fallible work in a request hook, then
// modify the request right before it is transmitted to the server; e.g.,
// for generating an authenticaiton signature based on the complete set of
// request header values:
req.headers_mut().insert(
reqwest::header::AUTHORIZATION,
reqwest::header::HeaderValue::from_str("legitimate")?,
);
Ok(())
}
fn all_done(_: &(), _result: &reqwest::Result<reqwest::Response>) {} fn all_done(_: &(), _result: &reqwest::Result<reqwest::Response>) {}
mod buildomat { mod buildomat {

View File

@ -249,6 +249,9 @@ pub enum Error<E = ()> {
/// A response not listed in the API description. This may represent a /// A response not listed in the API description. This may represent a
/// success or failure response; check `status().is_success()`. /// success or failure response; check `status().is_success()`.
UnexpectedResponse(reqwest::Response), UnexpectedResponse(reqwest::Response),
/// An error occurred in the processing of a request pre-hook.
PreHookError(String),
} }
impl<E> Error<E> { impl<E> Error<E> {
@ -256,6 +259,7 @@ impl<E> Error<E> {
pub fn status(&self) -> Option<reqwest::StatusCode> { pub fn status(&self) -> Option<reqwest::StatusCode> {
match self { match self {
Error::InvalidRequest(_) => None, Error::InvalidRequest(_) => None,
Error::PreHookError(_) => None,
Error::CommunicationError(e) => e.status(), Error::CommunicationError(e) => e.status(),
Error::ErrorResponse(rv) => Some(rv.status()), Error::ErrorResponse(rv) => Some(rv.status()),
Error::InvalidUpgrade(e) => e.status(), Error::InvalidUpgrade(e) => e.status(),
@ -272,6 +276,7 @@ impl<E> Error<E> {
pub fn into_untyped(self) -> Error { pub fn into_untyped(self) -> Error {
match self { match self {
Error::InvalidRequest(s) => Error::InvalidRequest(s), Error::InvalidRequest(s) => Error::InvalidRequest(s),
Error::PreHookError(s) => Error::PreHookError(s),
Error::CommunicationError(e) => Error::CommunicationError(e), Error::CommunicationError(e) => Error::CommunicationError(e),
Error::ErrorResponse(ResponseValue { Error::ErrorResponse(ResponseValue {
inner: _, inner: _,
@ -332,6 +337,9 @@ where
Error::UnexpectedResponse(r) => { Error::UnexpectedResponse(r) => {
write!(f, "Unexpected Response: {:?}", r) write!(f, "Unexpected Response: {:?}", r)
} }
Error::PreHookError(s) => {
write!(f, "Pre-hook Error: {}", s)
}
} }
} }
} }

View File

@ -60,6 +60,7 @@ pub struct GenerationSettings {
tag: TagStyle, tag: TagStyle,
inner_type: Option<TokenStream>, inner_type: Option<TokenStream>,
pre_hook: Option<TokenStream>, pre_hook: Option<TokenStream>,
pre_hook_async: Option<TokenStream>,
post_hook: Option<TokenStream>, post_hook: Option<TokenStream>,
extra_derives: Vec<String>, extra_derives: Vec<String>,
@ -128,6 +129,12 @@ impl GenerationSettings {
self self
} }
/// Hook invoked before issuing the HTTP request.
pub fn with_pre_hook_async(&mut self, pre_hook: TokenStream) -> &mut Self {
self.pre_hook_async = Some(pre_hook);
self
}
/// Hook invoked prior to receiving the HTTP response. /// Hook invoked prior to receiving the HTTP response.
pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self { pub fn with_post_hook(&mut self, post_hook: TokenStream) -> &mut Self {
self.post_hook = Some(post_hook); self.post_hook = Some(post_hook);

View File

@ -1141,6 +1141,14 @@ impl Generator {
(#hook)(&#client.inner, &#request_ident); (#hook)(&#client.inner, &#request_ident);
} }
}); });
let pre_hook_async = self.settings.pre_hook_async.as_ref().map(|hook| {
quote! {
match (#hook)(&#client.inner, &mut #request_ident).await {
Ok(_) => (),
Err(e) => return Err(Error::PreHookError(e.to_string())),
}
}
});
let post_hook = self.settings.post_hook.as_ref().map(|hook| { let post_hook = self.settings.post_hook.as_ref().map(|hook| {
quote! { quote! {
(#hook)(&#client.inner, &#result_ident); (#hook)(&#client.inner, &#result_ident);
@ -1155,7 +1163,8 @@ impl Generator {
#headers_build #headers_build
let #request_ident = #client.client #[allow(unused_mut)]
let mut #request_ident = #client.client
. #method_func (#url_ident) . #method_func (#url_ident)
#accept_header #accept_header
#(#body_func)* #(#body_func)*
@ -1165,6 +1174,7 @@ impl Generator {
.build()?; .build()?;
#pre_hook #pre_hook
#pre_hook_async
let #result_ident = #client.client let #result_ident = #client.client
.execute(#request_ident) .execute(#request_ident)
.await; .await;

View File

@ -2404,7 +2404,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/control/hold", client.baseurl,); let url = format!("{}/v1/control/hold", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2438,7 +2439,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/control/resume", client.baseurl,); let url = format!("{}/v1/control/resume", client.baseurl,);
let request = client.client.post(url).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -2484,7 +2486,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2518,7 +2521,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/tasks", client.baseurl,); let url = format!("{}/v1/tasks", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2579,7 +2583,8 @@ pub mod builder {
.and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/tasks", client.baseurl,); let url = format!("{}/v1/tasks", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2655,7 +2660,8 @@ pub mod builder {
if let Some(v) = &minseq { if let Some(v) = &minseq {
query.push(("minseq", v.to_string())); query.push(("minseq", v.to_string()));
} }
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2709,7 +2715,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2780,7 +2787,8 @@ pub mod builder {
encode_path(&task.to_string()), encode_path(&task.to_string()),
encode_path(&output.to_string()), encode_path(&output.to_string()),
); );
let request = client.client.get(url).build()?; #[allow(unused_mut)]
let mut request = client.client.get(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -2834,7 +2842,8 @@ pub mod builder {
.and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/users", client.baseurl,); let url = format!("{}/v1/users", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2869,7 +2878,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/whoami", client.baseurl,); let url = format!("{}/v1/whoami", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2919,7 +2929,8 @@ pub mod builder {
let Self { client, body } = self; let Self { client, body } = self;
let body = body.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/whoami/name", client.baseurl,); let url = format!("{}/v1/whoami/name", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -2981,7 +2992,8 @@ pub mod builder {
.and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/worker/bootstrap", client.baseurl,); let url = format!("{}/v1/worker/bootstrap", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3016,7 +3028,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/worker/ping", client.baseurl,); let url = format!("{}/v1/worker/ping", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3096,7 +3109,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3155,7 +3169,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3240,7 +3255,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3311,7 +3327,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3338,7 +3355,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WorkersResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WorkersResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/workers", client.baseurl,); let url = format!("{}/v1/workers", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3372,7 +3390,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/workers/recycle", client.baseurl,); let url = format!("{}/v1/workers/recycle", client.baseurl,);
let request = client.client.post(url).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -2404,7 +2404,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/control/hold", client.baseurl,); let url = format!("{}/v1/control/hold", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2438,7 +2439,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/control/resume", client.baseurl,); let url = format!("{}/v1/control/resume", client.baseurl,);
let request = client.client.post(url).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -2484,7 +2486,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2518,7 +2521,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/tasks", client.baseurl,); let url = format!("{}/v1/tasks", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2579,7 +2583,8 @@ pub mod builder {
.and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::TaskSubmit::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/tasks", client.baseurl,); let url = format!("{}/v1/tasks", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2655,7 +2660,8 @@ pub mod builder {
if let Some(v) = &minseq { if let Some(v) = &minseq {
query.push(("minseq", v.to_string())); query.push(("minseq", v.to_string()));
} }
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2709,7 +2715,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2780,7 +2787,8 @@ pub mod builder {
encode_path(&task.to_string()), encode_path(&task.to_string()),
encode_path(&output.to_string()), encode_path(&output.to_string()),
); );
let request = client.client.get(url).build()?; #[allow(unused_mut)]
let mut request = client.client.get(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -2834,7 +2842,8 @@ pub mod builder {
.and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::UserCreate::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/users", client.baseurl,); let url = format!("{}/v1/users", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -2869,7 +2878,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/whoami", client.baseurl,); let url = format!("{}/v1/whoami", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -2919,7 +2929,8 @@ pub mod builder {
let Self { client, body } = self; let Self { client, body } = self;
let body = body.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/whoami/name", client.baseurl,); let url = format!("{}/v1/whoami/name", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -2981,7 +2992,8 @@ pub mod builder {
.and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::WorkerBootstrap::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/v1/worker/bootstrap", client.baseurl,); let url = format!("{}/v1/worker/bootstrap", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3016,7 +3028,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/worker/ping", client.baseurl,); let url = format!("{}/v1/worker/ping", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3096,7 +3109,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3155,7 +3169,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3240,7 +3255,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3311,7 +3327,8 @@ pub mod builder {
client.baseurl, client.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -3338,7 +3355,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<types::WorkersResult>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<types::WorkersResult>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/workers", client.baseurl,); let url = format!("{}/v1/workers", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3372,7 +3390,8 @@ pub mod builder {
pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> { pub async fn send(self) -> Result<ResponseValue<()>, Error<()>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/v1/workers/recycle", client.baseurl,); let url = format!("{}/v1/workers/recycle", client.baseurl,);
let request = client.client.post(url).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -827,7 +827,8 @@ impl Client {
///Sends a `POST` request to `/v1/control/hold` ///Sends a `POST` request to `/v1/control/hold`
pub async fn control_hold<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> { pub async fn control_hold<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/control/hold", self.baseurl,); let url = format!("{}/v1/control/hold", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -846,7 +847,8 @@ impl Client {
///Sends a `POST` request to `/v1/control/resume` ///Sends a `POST` request to `/v1/control/resume`
pub async fn control_resume<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> { pub async fn control_resume<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/control/resume", self.baseurl,); let url = format!("{}/v1/control/resume", self.baseurl,);
let request = self.client.post(url).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -865,7 +867,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -884,7 +887,8 @@ impl Client {
///Sends a `GET` request to `/v1/tasks` ///Sends a `GET` request to `/v1/tasks`
pub async fn tasks_get<'a>(&'a self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> { pub async fn tasks_get<'a>(&'a self) -> Result<ResponseValue<Vec<types::Task>>, Error<()>> {
let url = format!("{}/v1/tasks", self.baseurl,); let url = format!("{}/v1/tasks", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -906,7 +910,8 @@ impl Client {
body: &'a types::TaskSubmit, body: &'a types::TaskSubmit,
) -> Result<ResponseValue<types::TaskSubmitResult>, Error<()>> { ) -> Result<ResponseValue<types::TaskSubmitResult>, Error<()>> {
let url = format!("{}/v1/tasks", self.baseurl,); let url = format!("{}/v1/tasks", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -939,7 +944,8 @@ impl Client {
query.push(("minseq", v.to_string())); query.push(("minseq", v.to_string()));
} }
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -966,7 +972,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -994,7 +1001,8 @@ impl Client {
encode_path(&task.to_string()), encode_path(&task.to_string()),
encode_path(&output.to_string()), encode_path(&output.to_string()),
); );
let request = self.client.get(url).build()?; #[allow(unused_mut)]
let mut request = self.client.get(url).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -1009,7 +1017,8 @@ impl Client {
body: &'a types::UserCreate, body: &'a types::UserCreate,
) -> Result<ResponseValue<types::UserCreateResult>, Error<()>> { ) -> Result<ResponseValue<types::UserCreateResult>, Error<()>> {
let url = format!("{}/v1/users", self.baseurl,); let url = format!("{}/v1/users", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -1029,7 +1038,8 @@ impl Client {
///Sends a `GET` request to `/v1/whoami` ///Sends a `GET` request to `/v1/whoami`
pub async fn whoami<'a>(&'a self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> { pub async fn whoami<'a>(&'a self) -> Result<ResponseValue<types::WhoamiResult>, Error<()>> {
let url = format!("{}/v1/whoami", self.baseurl,); let url = format!("{}/v1/whoami", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -1051,7 +1061,8 @@ impl Client {
body: String, body: String,
) -> Result<ResponseValue<()>, Error<()>> { ) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/whoami/name", self.baseurl,); let url = format!("{}/v1/whoami/name", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.put(url) .put(url)
.header( .header(
@ -1074,7 +1085,8 @@ impl Client {
body: &'a types::WorkerBootstrap, body: &'a types::WorkerBootstrap,
) -> Result<ResponseValue<types::WorkerBootstrapResult>, Error<()>> { ) -> Result<ResponseValue<types::WorkerBootstrapResult>, Error<()>> {
let url = format!("{}/v1/worker/bootstrap", self.baseurl,); let url = format!("{}/v1/worker/bootstrap", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -1096,7 +1108,8 @@ impl Client {
&'a self, &'a self,
) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> { ) -> Result<ResponseValue<types::WorkerPingResult>, Error<()>> {
let url = format!("{}/v1/worker/ping", self.baseurl,); let url = format!("{}/v1/worker/ping", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -1123,7 +1136,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).json(&body).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -1143,7 +1157,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -1175,7 +1190,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).json(&body).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -1195,7 +1211,8 @@ impl Client {
self.baseurl, self.baseurl,
encode_path(&task.to_string()), encode_path(&task.to_string()),
); );
let request = self.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).json(&body).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {
@ -1209,7 +1226,8 @@ impl Client {
&'a self, &'a self,
) -> Result<ResponseValue<types::WorkersResult>, Error<()>> { ) -> Result<ResponseValue<types::WorkersResult>, Error<()>> {
let url = format!("{}/v1/workers", self.baseurl,); let url = format!("{}/v1/workers", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -1228,7 +1246,8 @@ impl Client {
///Sends a `POST` request to `/v1/workers/recycle` ///Sends a `POST` request to `/v1/workers/recycle`
pub async fn workers_recycle<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> { pub async fn workers_recycle<'a>(&'a self) -> Result<ResponseValue<()>, Error<()>> {
let url = format!("{}/v1/workers/recycle", self.baseurl,); let url = format!("{}/v1/workers/recycle", self.baseurl,);
let request = self.client.post(url).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -1436,7 +1436,8 @@ pub mod builder {
let url = format!("{}/enrol", client.baseurl,); let url = format!("{}/enrol", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.json(&body) .json(&body)
@ -1488,7 +1489,8 @@ pub mod builder {
let url = format!("{}/global/jobs", client.baseurl,); let url = format!("{}/global/jobs", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -1543,7 +1545,8 @@ pub mod builder {
let url = format!("{}/ping", client.baseurl,); let url = format!("{}/ping", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -1626,7 +1629,8 @@ pub mod builder {
let url = format!("{}/report/finish", client.baseurl,); let url = format!("{}/report/finish", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -1710,7 +1714,8 @@ pub mod builder {
let url = format!("{}/report/output", client.baseurl,); let url = format!("{}/report/output", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -1792,7 +1797,8 @@ pub mod builder {
let url = format!("{}/report/start", client.baseurl,); let url = format!("{}/report/start", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(

View File

@ -1436,7 +1436,8 @@ pub mod builder {
let url = format!("{}/enrol", client.baseurl,); let url = format!("{}/enrol", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.json(&body) .json(&body)
@ -1488,7 +1489,8 @@ pub mod builder {
let url = format!("{}/global/jobs", client.baseurl,); let url = format!("{}/global/jobs", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -1543,7 +1545,8 @@ pub mod builder {
let url = format!("{}/ping", client.baseurl,); let url = format!("{}/ping", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -1626,7 +1629,8 @@ pub mod builder {
let url = format!("{}/report/finish", client.baseurl,); let url = format!("{}/report/finish", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -1710,7 +1714,8 @@ pub mod builder {
let url = format!("{}/report/output", client.baseurl,); let url = format!("{}/report/output", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -1792,7 +1797,8 @@ pub mod builder {
let url = format!("{}/report/start", client.baseurl,); let url = format!("{}/report/start", client.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(

View File

@ -524,7 +524,8 @@ impl Client {
let url = format!("{}/enrol", self.baseurl,); let url = format!("{}/enrol", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.json(&body) .json(&body)
@ -549,7 +550,8 @@ impl Client {
let url = format!("{}/global/jobs", self.baseurl,); let url = format!("{}/global/jobs", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -577,7 +579,8 @@ impl Client {
let url = format!("{}/ping", self.baseurl,); let url = format!("{}/ping", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -607,7 +610,8 @@ impl Client {
let url = format!("{}/report/finish", self.baseurl,); let url = format!("{}/report/finish", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -638,7 +642,8 @@ impl Client {
let url = format!("{}/report/output", self.baseurl,); let url = format!("{}/report/output", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -669,7 +674,8 @@ impl Client {
let url = format!("{}/report/start", self.baseurl,); let url = format!("{}/report/start", self.baseurl,);
let mut header_map = HeaderMap::with_capacity(1usize); let mut header_map = HeaderMap::with_capacity(1usize);
header_map.append("Authorization", HeaderValue::try_from(authorization)?); header_map.append("Authorization", HeaderValue::try_from(authorization)?);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -253,7 +253,8 @@ pub mod builder {
_query.push(("response", response.to_string())); _query.push(("response", response.to_string()));
_query.push(("result", result.to_string())); _query.push(("result", result.to_string()));
_query.push(("url", url.to_string())); _query.push(("url", url.to_string()));
let _request = _client.client.get(_url).query(&_query).build()?; #[allow(unused_mut)]
let mut _request = _client.client.get(_url).query(&_query).build()?;
let _result = _client.client.execute(_request).await; let _result = _client.client.execute(_request).await;
let _response = _result?; let _response = _result?;
match _response.status().as_u16() { match _response.status().as_u16() {

View File

@ -253,7 +253,8 @@ pub mod builder {
_query.push(("response", response.to_string())); _query.push(("response", response.to_string()));
_query.push(("result", result.to_string())); _query.push(("result", result.to_string()));
_query.push(("url", url.to_string())); _query.push(("url", url.to_string()));
let _request = _client.client.get(_url).query(&_query).build()?; #[allow(unused_mut)]
let mut _request = _client.client.get(_url).query(&_query).build()?;
let _result = _client.client.execute(_request).await; let _result = _client.client.execute(_request).await;
let _response = _result?; let _response = _result?;
match _response.status().as_u16() { match _response.status().as_u16() {

View File

@ -131,7 +131,8 @@ impl Client {
_query.push(("response", response.to_string())); _query.push(("response", response.to_string()));
_query.push(("result", result.to_string())); _query.push(("result", result.to_string()));
_query.push(("url", url.to_string())); _query.push(("url", url.to_string()));
let _request = self.client.get(_url).query(&_query).build()?; #[allow(unused_mut)]
let mut _request = self.client.get(_url).query(&_query).build()?;
let _result = self.client.execute(_request).await; let _result = self.client.execute(_request).await;
let _response = _result?; let _response = _result?;
match _response.status().as_u16() { match _response.status().as_u16() {

View File

@ -190,7 +190,8 @@ pub mod builder {
if let Some(v) = &unique_key { if let Some(v) = &unique_key {
query.push(("uniqueKey", v.to_string())); query.push(("uniqueKey", v.to_string()));
} }
let request = client.client.get(url).query(&query).build()?; #[allow(unused_mut)]
let mut request = client.client.get(url).query(&query).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -190,7 +190,8 @@ pub mod builder {
if let Some(v) = &unique_key { if let Some(v) = &unique_key {
query.push(("uniqueKey", v.to_string())); query.push(("uniqueKey", v.to_string()));
} }
let request = client.client.get(url).query(&query).build()?; #[allow(unused_mut)]
let mut request = client.client.get(url).query(&query).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -128,7 +128,8 @@ impl Client {
query.push(("uniqueKey", v.to_string())); query.push(("uniqueKey", v.to_string()));
} }
let request = self.client.get(url).query(&query).build()?; #[allow(unused_mut)]
let mut request = self.client.get(url).query(&query).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -3002,7 +3002,8 @@ pub mod builder {
) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/instance", client.baseurl,); let url = format!("{}/instance", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3075,7 +3076,8 @@ pub mod builder {
.and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance", client.baseurl,); let url = format!("{}/instance", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -3154,7 +3156,8 @@ pub mod builder {
encode_path(&id.to_string()), encode_path(&id.to_string()),
encode_path(&snapshot_id.to_string()), encode_path(&snapshot_id.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3231,7 +3234,8 @@ pub mod builder {
}) })
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/migrate/status", client.baseurl,); let url = format!("{}/instance/migrate/status", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3274,7 +3278,8 @@ pub mod builder {
) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> { ) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/instance/serial", client.baseurl,); let url = format!("{}/instance/serial", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header(reqwest::header::CONNECTION, "Upgrade") .header(reqwest::header::CONNECTION, "Upgrade")
@ -3330,7 +3335,8 @@ pub mod builder {
let Self { client, body } = self; let Self { client, body } = self;
let body = body.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/state", client.baseurl,); let url = format!("{}/instance/state", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -3408,7 +3414,8 @@ pub mod builder {
}) })
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/state-monitor", client.baseurl,); let url = format!("{}/instance/state-monitor", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(

View File

@ -2966,7 +2966,8 @@ pub mod builder {
) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/instance", client.baseurl,); let url = format!("{}/instance", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3039,7 +3040,8 @@ pub mod builder {
.and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::InstanceEnsureRequest::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance", client.baseurl,); let url = format!("{}/instance", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -3118,7 +3120,8 @@ pub mod builder {
encode_path(&id.to_string()), encode_path(&id.to_string()),
encode_path(&snapshot_id.to_string()), encode_path(&snapshot_id.to_string()),
); );
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.post(url) .post(url)
.header( .header(
@ -3195,7 +3198,8 @@ pub mod builder {
}) })
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/migrate/status", client.baseurl,); let url = format!("{}/instance/migrate/status", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(
@ -3238,7 +3242,8 @@ pub mod builder {
) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> { ) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> {
let Self { client } = self; let Self { client } = self;
let url = format!("{}/instance/serial", client.baseurl,); let url = format!("{}/instance/serial", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header(reqwest::header::CONNECTION, "Upgrade") .header(reqwest::header::CONNECTION, "Upgrade")
@ -3294,7 +3299,8 @@ pub mod builder {
let Self { client, body } = self; let Self { client, body } = self;
let body = body.map_err(Error::InvalidRequest)?; let body = body.map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/state", client.baseurl,); let url = format!("{}/instance/state", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.put(url) .put(url)
.header( .header(
@ -3372,7 +3378,8 @@ pub mod builder {
}) })
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/instance/state-monitor", client.baseurl,); let url = format!("{}/instance/state-monitor", client.baseurl,);
let request = client #[allow(unused_mut)]
let mut request = client
.client .client
.get(url) .get(url)
.header( .header(

View File

@ -1491,7 +1491,8 @@ impl Client {
&'a self, &'a self,
) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceGetResponse>, Error<types::Error>> {
let url = format!("{}/instance", self.baseurl,); let url = format!("{}/instance", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -1519,7 +1520,8 @@ impl Client {
body: &'a types::InstanceEnsureRequest, body: &'a types::InstanceEnsureRequest,
) -> Result<ResponseValue<types::InstanceEnsureResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceEnsureResponse>, Error<types::Error>> {
let url = format!("{}/instance", self.baseurl,); let url = format!("{}/instance", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.put(url) .put(url)
.header( .header(
@ -1556,7 +1558,8 @@ impl Client {
encode_path(&id.to_string()), encode_path(&id.to_string()),
encode_path(&snapshot_id.to_string()), encode_path(&snapshot_id.to_string()),
); );
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.post(url) .post(url)
.header( .header(
@ -1584,7 +1587,8 @@ impl Client {
body: &'a types::InstanceMigrateStatusRequest, body: &'a types::InstanceMigrateStatusRequest,
) -> Result<ResponseValue<types::InstanceMigrateStatusResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceMigrateStatusResponse>, Error<types::Error>> {
let url = format!("{}/instance/migrate/status", self.baseurl,); let url = format!("{}/instance/migrate/status", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(
@ -1612,7 +1616,8 @@ impl Client {
&'a self, &'a self,
) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> { ) -> Result<ResponseValue<reqwest::Upgraded>, Error<reqwest::Upgraded>> {
let url = format!("{}/instance/serial", self.baseurl,); let url = format!("{}/instance/serial", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header(reqwest::header::CONNECTION, "Upgrade") .header(reqwest::header::CONNECTION, "Upgrade")
@ -1641,7 +1646,8 @@ impl Client {
body: types::InstanceStateRequested, body: types::InstanceStateRequested,
) -> Result<ResponseValue<()>, Error<types::Error>> { ) -> Result<ResponseValue<()>, Error<types::Error>> {
let url = format!("{}/instance/state", self.baseurl,); let url = format!("{}/instance/state", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.put(url) .put(url)
.header( .header(
@ -1670,7 +1676,8 @@ impl Client {
body: &'a types::InstanceStateMonitorRequest, body: &'a types::InstanceStateMonitorRequest,
) -> Result<ResponseValue<types::InstanceStateMonitorResponse>, Error<types::Error>> { ) -> Result<ResponseValue<types::InstanceStateMonitorResponse>, Error<types::Error>> {
let url = format!("{}/instance/state-monitor", self.baseurl,); let url = format!("{}/instance/state-monitor", self.baseurl,);
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(

View File

@ -446,7 +446,8 @@ pub mod builder {
.and_then(|v| types::BodyWithDefaults::try_from(v).map_err(|e| e.to_string())) .and_then(|v| types::BodyWithDefaults::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?; .map_err(Error::InvalidRequest)?;
let url = format!("{}/", client.baseurl,); let url = format!("{}/", client.baseurl,);
let request = client.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = client.client.post(url).json(&body).build()?;
let result = client.client.execute(request).await; let result = client.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -215,7 +215,8 @@ impl Client {
body: &'a types::BodyWithDefaults, body: &'a types::BodyWithDefaults,
) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> { ) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> {
let url = format!("{}/", self.baseurl,); let url = format!("{}/", self.baseurl,);
let request = self.client.post(url).json(&body).build()?; #[allow(unused_mut)]
let mut request = self.client.post(url).json(&body).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -147,7 +147,8 @@ impl Client {
&'a self, &'a self,
) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> { ) -> Result<ResponseValue<ByteStream>, Error<ByteStream>> {
let url = format!("{}/", self.baseurl,); let url = format!("{}/", self.baseurl,);
let request = self.client.get(url).build()?; #[allow(unused_mut)]
let mut request = self.client.get(url).build()?;
let result = self.client.execute(request).await; let result = self.client.execute(request).await;
let response = result?; let response = result?;
match response.status().as_u16() { match response.status().as_u16() {

View File

@ -163,7 +163,8 @@ impl Client {
query.push(("if", if_.to_string())); query.push(("if", if_.to_string()));
query.push(("in", in_.to_string())); query.push(("in", in_.to_string()));
query.push(("use", use_.to_string())); query.push(("use", use_.to_string()));
let request = self #[allow(unused_mut)]
let mut request = self
.client .client
.get(url) .get(url)
.header( .header(

View File

@ -91,6 +91,7 @@ struct MacroSettings {
inner_type: Option<ParseWrapper<syn::Type>>, inner_type: Option<ParseWrapper<syn::Type>>,
pre_hook: Option<ParseWrapper<ClosureOrPath>>, pre_hook: Option<ParseWrapper<ClosureOrPath>>,
pre_hook_async: Option<ParseWrapper<ClosureOrPath>>,
post_hook: Option<ParseWrapper<ClosureOrPath>>, post_hook: Option<ParseWrapper<ClosureOrPath>>,
#[serde(default)] #[serde(default)]
@ -193,6 +194,7 @@ fn do_generate_api(item: TokenStream) -> Result<TokenStream, syn::Error> {
tags, tags,
inner_type, inner_type,
pre_hook, pre_hook,
pre_hook_async,
post_hook, post_hook,
derives, derives,
patch, patch,
@ -207,6 +209,9 @@ fn do_generate_api(item: TokenStream) -> Result<TokenStream, syn::Error> {
}); });
pre_hook pre_hook
.map(|pre_hook| settings.with_pre_hook(pre_hook.into_inner().0)); .map(|pre_hook| settings.with_pre_hook(pre_hook.into_inner().0));
pre_hook_async.map(|pre_hook_async| {
settings.with_pre_hook_async(pre_hook_async.into_inner().0)
});
post_hook post_hook
.map(|post_hook| settings.with_post_hook(post_hook.into_inner().0)); .map(|post_hook| settings.with_post_hook(post_hook.into_inner().0));